SQL Server 2008 Query

  • Thank a lot for the information guys! This really helped. I do have one more question 

    Say I have the following data 

    Customer RowNum SalesOrder Customer Quoted Hours
    (100915) (2) (100915-2) (ARORA) (NULL)
    (100915) (1) (100915-1) (ARORA) (10)
    (100576) (1) (100576-1 ) (AMKOR)  (12)
    (100555) (1) ( 100555-1 ) (JACK) (8)

    Is there anyway to copy the quoted hours from where rownum is 1 to the null value?

    I was thinking something like this. But its not working correctly

    UPDATE (TABLE NAME) 
    SET QuoteHours = QuoteHours
    WHERE RowNum = 2
    AND ORderNum IN ( SELECT OrderNum FROM #temptable WHERE RowNum = 1);
        

  • ajkarora - Wednesday, January 25, 2017 12:17 PM

    Thank a lot for the information guys! This really helped. I do have one more question 

    Say I have the following data 

    Customer RowNum SalesOrder Customer Quoted Hours
    (100915) (2) (100915-2) (ARORA) (NULL)
    (100915) (1) (100915-1) (ARORA) (10)
    (100576) (1) (100576-1 ) (AMKOR)  (12)
    (100555) (1) ( 100555-1 ) (JACK) (8)

    Is there anyway to copy the quoted hours from where rownum is 1 to the null value?

    I was thinking something like this. But its not working correctly

    UPDATE (TABLE NAME) 
    SET QuoteHours = QuoteHours
    WHERE RowNum = 2
    AND ORderNum IN ( SELECT OrderNum FROM #temptable WHERE RowNum = 1);
        

    What value do you expect in "Quoted Hours" for row with RowNum = 3 if your data looks like this?


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

Viewing 3 posts - 16 through 17 (of 17 total)

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