Update Statement

  • Hi Everyone , I'm inserting 24 months data into table based on some calculation...I have got a roll of date column in table which is different for each employee...So if roll of data is January remaining 22 months hours should be zero. So data only populate for Dec and Jan months..

    Below is the sample query for 2months..!

    SELECT [FINALEID],[RESOURCEHOME],[ROLLOFFDATE] ,PROJECT,Client,WBSE,

    CASE WHEN WORKINGDAYSCOMPLETEDINMONTH1 IS NULLL THEN STANDARDHOURSFORMONTH1

    ELSE CALCULATEDHOURSCOMPLETEDINMONTH1

    END AS HOURSFORMONTH1,

    CASE WHEN WORKINGDAYSCOMPLETEDINMONTH2 IS NULL THEN STANDARDHOURSFORMONTH2

    ELSE CALCULATEDHOURSCOMPLETEDINMONTH2

    END AS HOURSFORMONTH2

    FROM #COMPAREHOURS A JOIN #COMPAREHOURS B ON A.FINALEID=B.FINALEID

    If you have any questions, please let me know....any help greatly appreciated ..Thanks.

  • It's very difficult to figure out what you are asking and what you are expecting as a result. Can you post some sample data and what you are expecting to happen?

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • There's no actual question here, so we don't know how we can help. Without knowing what your temp table looks like, it's going to be impossible to answer most questions. I do notice that you're doing a self-join on your temp table but your join predicate is on the same column, so I guess I don't see the point.

    The DDL, some sample data and what you expect for your output is a good start. Please see the link in my signature on how to ask questions to have the best chance of getting an answer.

Viewing 3 posts - 1 through 2 (of 2 total)

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