You must Sign In to post a response.
  • Category: SQL Server

    How to find missing numbers in two columns using sql server ?

    how to find missing numbers in two columns using sql server ?

    Example

    Colmn1 Colmn2
    1 20
    22 30
    35 40
    41 60

    From above solution the no

    21, 31,32,33,34 are missing from sequence.......

    Please help me to solve this query......!
  • #761624
    Hello Ajit More,

    I am not clear with your query what you are going to do. Please elaborate your query to get exact and faster result.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761625
    Hi I have two column in my table like

    eg:-

    Colmn1 Colmn2
    1 20
    22 30
    35 40
    41 60


    I want output like this:

    Missing Value like

    21, 31,32,33,34

    so how to get this result


    check Attach File

  • #761626

    Delete Attachment

  • #761627
    1. According to me to do this in single query is little bit difficult
    2. You can write Stored Procedure to do this.
    3. Or you can do this your BOL

    By Nathan
    Direction is important than speed

  • #761744
    My way is join the row with next row. Look like:
    Colmn1 Colmn2 Colomn3 column4
    1 20 22 30
    22 30 35 40
    35 40 41 60
    41 60 null null

    Then we can select a list from column 2 and 3 like this:
    20 22
    30 35
    40 41
    60 null

    Loop for each row to find the missing values.


Sign In to post your comments