All Forums Database
patilsantosh 7 posts Joined 07/15
09 Jul 2015
TO GET LASTEST VALUES FOR NULL IN QUALIFYS

in the below table TABLE1
PID,NAME,DATE_MODIFIED
1,XYZ,NULL
1,XYZ,'12-12-2014
2,AAA,NULL
2,AA,NULL
     MY QUERY TO GET LATEST RECORD:-
 SELECT PID,NAME,DATE_MODIFIED FROM TABLE1
QUALIFY ROW_NUMBER()  OVER (PARTITON BY PID ORDER BY DATE_MODIFIED DESC)=1
To get the lastest record ,i am writing ABOVE query?SO IT WILL WORK FOR NULL VALUES FOR TO GET LASTEST VALUES.
 

dnoeth 4628 posts Joined 11/04
09 Jul 2015

How do you define latest for NULLs?
Your query returns the row with the latest date per PID, if all DATE_MODIFIED are NULL it returns a random row.

Dieter

patilsantosh 7 posts Joined 07/15
14 Jul 2015

i had taken another key column and it is working

You must sign in to leave a comment.