Unanswered: Order by causing problems in sub query
Hi I am trying to get the latest logon time for each user in the second subquery. However when I use order by in the second sub query I get the error: "ORA - 00907: missing right parenthesis". I am using version 9i, is it possible to do this as one query or will I need two seperate ones?
FROM log_history t2
WHERE userId = t1.userId),
FROM log_history t3
WHERE rownum =1
AND t3.userId= t1.userId
ORDER BY logon_dtime)
where t3.user_id = t1.user_id
Assuming logon_dtime is a date column, which if its a date, should be a date column. That would be one way to do it.
Ok on 2nd thought I would personally do something more along the lines of this:
from users t1,
group by userid) t2
where t1.userid = t2.userid
This should fit it all in one query, and get what you need - i'm not connected to test, but it looks like it should be close