I will try to explain what I am trying to achieve quickly, since I have no idea how to explain it otherwise!
We have a table that shows the entire employment history for all employees, I want to "Start_Date" the current message ("Current_Flag" = "Y"). Also, I want the "End_Date" message before (going to filter by the current flag, sort by end date and just grab the top one)
Anyway, here is my code:
SELECT "Gc_Staff_Number", "Start_Date", (SELECT "End_Date" FROM "Employment_History" WHERE "Current_Flag" != 'Y' AND ROWNUM = 1 AND "Employee_Number" = "Employment_History"."Employee_Number" ORDER BY "End_Date" ASC) FROM "Employment_History" WHERE "Current_Flag" = 'Y'
Any suggestions on how to get this job will be fantastic, we hope that the above makes a little sense - to be honest, at the moment the request will not work, which really sucks, hmm.
(edit: Oh! I am writing this to query an existing system ... which for some reason has all the silly double quotes around table and field names, sigh!)
source share