i generally just use pretty basic SQL, for the life of me i can't figure out how to approach this...
using SQL I need to find the newest date from three different date fields. i was thinking case statements; but, maybe i'm just using them wrong?
SELECT PAT.Update_Date, PADD.Update_Date, PELG.Update_Date,
CASE WHEN
(CASE WHEN PAT.Update_Date >= PADD.Update_Date THEN PAT.Update_Date ELSE PADD.Update_Date END AS PATvsPADD) >=
(CASE WHEN PAT.Update_Date >= PELG.Update_Date THEN PAT.Update_Date ELSE PELG.Update_Date END AS PATvsPELG)
THEN PATvsPADD ELSE PATvsPELG END AS WhoWins
FROM PAT, PADD, PELG
WHERE PAT.Id = PADD.Id AND PADD.Id = PELG.Id
obviously, this isn't working out for me, or i wouldn't be here. but, am i even headed in the right direction?
after i get the select business down, i need to modify the where so i can check against a date, i.e. have any of these dates been updated in the past two weeks?
Posts
now to get the where clause to work off of that, gonna just try a nested select with this code.
Oracle
http://www.techonthenet.com/oracle/functions/greatest.php
MySQL has this too. SQLServer is the odd man out.
I think that's kosher in Oracle.
oh my, so much cleaner
thanks!