Can you please help me to get the median using the cursor

  • Can you please help me to get the median using the cursor

    How I wrote the following code using the cursor

    Do I really need help please

    UPDATE tblGas01G4C40Total

    SET Median Consumption =

    (((SELECT Max( DailyConsumption ) FROM

    (SELECT TOP 50 PERCENT DailyConsumption

    FROM participation_cntInformation_Archieve90 INNER JOIN

    tblGas01G4C40Total ON participation_cntInformation_Archieve90.ID_NO= tblGas01G4C40Total.ID_No

    ORDER BY masrafrozane)As h1)

    +

    (SELECT MIN( DailyConsumption )

    FROM(SELECT TOP 50 PERCENT DailyConsumption

    FROM participation_cntInformation_Archieve90 INNER JOIN

    tblGas01G4C40Total ON participation_cntInformation_Archieve90.ID_NO= tblGas01G4C40Total.ID_No

    ORDER BY masrafrozane DESC) AS h2))/2)

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • This is a repeated post and was solved in here

    http://www.sqlservercentral.com/Forums/Topic1329746-392-1.aspx

    By the way, I made the same mistake as Stewart

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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