Reputation: 33
In my query
Select AT.PRE_LAST_DATE
From AUTHORIZATION AT
Where AT.PROJECT_ID = 5 and AT.PRE_DESIG_ID = 48
Order By AT.ID Desc;
I am getting two dates
But when I use Rownum = 1
, it does not return null value
Select AT.PRE_LAST_DATE
From AUTHORIZATION AT
Where AT.PROJECT_ID = 5 and AT.PRE_DESIG_ID = 48 and ROWNUM = 1
Order By AT.ID Desc;
It returns:
Now how do I get the first null value?
Upvotes: 2
Views: 590
Reputation: 1274
The ORDER BY
is applied after the WHERE
clause, which returns only one of the rows in undefined order. To order first, then select the top row, use a subquery:
Select PRE_LAST_DATE
From
(Select AT.PRE_LAST_DATE From
AUTHORIZATION AT
Where AT.PROJECT_ID = 5 and AT.PRE_DESIG_ID = 48
Order By AT.ID Desc)
Where ROWNUM = 1;
Upvotes: 2