All Forums UDA
rlaskar 18 posts Joined 03/06
26 Apr 2006
SQL syntax to check values in a group

Hi All,I am trying to verify a table group by say ss_id, and say it returns 10 rows (same ss_id). Now I am trying to verify whether 10th row value > 9th row, 9th row > 8th row ...I need some feedback on way of resolving the problem.with regards,rlaskar

DEEPU 9 posts Joined 10/05
05 May 2006

Hi,Look for the "PREV_VALUE" & "RESULT" logic in below query.SEL SS_ID, CURR_VALUE, (SUM(CURR_VALUE)OVER(ROWS 1 PRECEDING) - CURR_VALUE) "PREV_VALUE" ,(CASE WHEN CURR_VALUE > PREV_VALUE THEN 'TRUE' WHEN CURR_VALUE = PREV_VALUE THEN 'EQUAL' ELSE 'FALSE' END) "RESULT"FROM(SEL SS_ID,SUM(X) "CURR_VALUE" FROM XYZGROUP BY 1)AIs this solution right for your requirement?

You must sign in to leave a comment.