Anoop kumar V <mailto:[EMAIL PROTECTED]> wrote:

> well - actually it might not be the last 2 days - i just want 2 of
> the latest records for every task regardless of what date it is in
> the table.  

Okay, now I think I understand what you need - and if I am correct, this
looks like one of the more exotic querys to me, but then again, I'm not like
the SQL king around, but let me give it a shot:

SELECT t1.id_secr_rqst, t2.name_rec_type, t1.dt_aud_rec, MAX(dt_aud_rec)
Latest, MAX(dt_aud_rec) NoSoLatest
FROM isr2_aud_log t1, isr2_aud_log t2
WHERE t1.id_secr_rqst = t2.id_secr_rqst
AND t1.name_rec_type='Exception Resource'
AND dt_aud_rec = Latest
OR dt_aud_rec = NoSoLatest
HAVING Latest > NoSoLatest
GROUP BY t1.id_secr_rqst
ORDER by t1.dt_aud_rec DESC;

I am not 100% sure about the syntax, but you might get the idea.

Peter Normann


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to