Finding transposed data

  • Exactly.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I may not have explained this as well as I could have... This list (1,-1,10,-10,...) works because if you take any whole positive number and change just one digit by only +1 or -1, then the resulting difference between the correct value and the modified value is:

    (+1/-1)*10^n

    where "n" is what digit-place was changed (counting from the right, starting at 0).

    I am very curious to know the logic.

    Say for example,I have choosen 1200 - Whole positive number.

    After that what you are doing by using the above formula ? How this logic match with your code ?

    Can you explain it more detail ?

    Greg,

    Just wanted to know about 'fat fingers'. what it means ? 🙂

    karthik

  • CREATE TABLE #test

    (

    CustID int,

    id int

    )

    INSERT INTO #test

    SELECT 100,1200 UNION ALL

    SELECT 100,1201 UNION ALL

    SELECT 600,1233 UNION ALL

    SELECT 600,1232 UNION ALL

    SELECT 700,1000 UNION ALL

    SELECT 700,1000 UNION ALL

    SELECT 800,2001 UNION ALL

    SELECT 800,2002 UNION ALL

    SELECT 900,1500 UNION ALL

    SELECT 900,1500

    SELECT

    t1.CustID,

    t1.id

    FROM #test t1,

    #test t2

    WHERE t1.CustID = t2.CustID

    AND (t1.id - t2.id) IN (1,-1)

    The above code also gave the correct result. Then why you added 10,-10,100,-1000 etc.,

    karthik

  • Numbers that are off by "1" for a single digit only from the "correct" number 1203:

    1202

    1204

    1213

    1303

    1103

    0203

    2203

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply