TO GET LASTEST VALUES FOR NULL IN QUALIFYS

Database
Enthusiast

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.

2 REPLIES
Senior Apprentice

Re: TO GET LASTEST VALUES FOR NULL IN QUALIFYS

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.

Enthusiast

Re: TO GET LASTEST VALUES FOR NULL IN QUALIFYS

i had taken another key column and it is working