Reputation: 45
I tried this query and got error. The sub query alone returns the desired result.
Select *
from usi
where present_date = select subdate(MAX(present_date), 1) AS PreviousDate from usi
What am I not doing correctly?
Upvotes: 1
Views: 383
Reputation: 1269445
You need parentheses around a subquery:
Select *
from usi
where present_date = (select subdate(MAX(present_date), 1) AS PreviousDate from usi);
As a note: subdate()
-- while completely valid -- looks strange. I'm more used to seeing date_sub()
or - interval 1 day
.
Upvotes: 1