RE: Retrieve most recent of multiple rows

2013-03-18 Thread Rick James
that as an exercise for the student.) -Original Message- From: Johan De Meersman [mailto:vegiv...@tuxera.be] Sent: Thursday, March 14, 2013 8:29 AM To: Ananda Kumar Cc: MySQL; Stefan Kuhn Subject: Re: Retrieve most recent of multiple rows - Original Message - From: Ananda Kumar

Re: Retrieve most recent of multiple rows

2013-03-15 Thread Marcus Vinicius
: Retrieve most recent of multiple rows select * from tab where anwer_timestamp in (select max(anwer_timestamp) from tab where q_id in (select distinct q_id from tab) group by q_id); This is entirely equivalent to select * from tab where anwer_timestamp in (select max(anwer_timestamp

Re: Retrieve most recent of multiple rows

2013-03-15 Thread hsv
2013/03/13 13:18 +, Norah Jones I have a table which looks like this: answer_id q_id answer qscore_id answer_timestamp 1 10Male3 1363091016 2 10Male3 1363091017 3 11Male3 1363091018 4

Re: Retrieve most recent of multiple rows

2013-03-14 Thread Ananda Kumar
not all the rows, only the distinct q_id, On Wed, Mar 13, 2013 at 8:28 PM, Johan De Meersman vegiv...@tuxera.bewrote: -- *From: *Ananda Kumar anan...@gmail.com *Subject: *Re: Retrieve most recent of multiple rows select qid,max(atimestamp) from kkk where qid

Aw: Re: Retrieve most recent of multiple rows

2013-03-14 Thread Stefan Kuhn
De Meersman vegiv...@tuxera.bewrote: -- *From: *Ananda Kumar anan...@gmail.com *Subject: *Re: Retrieve most recent of multiple rows select qid,max(atimestamp) from kkk where qid in (select distinct qid from kkk) group by qid; What use is that where statement

Re: Re: Retrieve most recent of multiple rows

2013-03-14 Thread Ananda Kumar
: -- *From: *Ananda Kumar anan...@gmail.com *Subject: *Re: Retrieve most recent of multiple rows select qid,max(atimestamp) from kkk where qid in (select distinct qid from kkk) group by qid; What use is that where statement? It just says to use all the rows in the table

Re: Retrieve most recent of multiple rows

2013-03-14 Thread Johan De Meersman
- Original Message - From: Ananda Kumar anan...@gmail.com Subject: Re: Re: Retrieve most recent of multiple rows select * from tab where anwer_timestamp in (select max(anwer_timestamp) from tab where q_id in (select distinct q_id from tab) group by q_id); This is entirely

Re: Retrieve most recent of multiple rows

2013-03-13 Thread Johan De Meersman
- Original Message - From: Norah Jones nh.jone...@gmail.com Subject: Retrieve most recent of multiple rows 4 10Male3 1363091019 5 11Male3 1363091020 6 12Male3 1363091020 7 11

Re: Retrieve most recent of multiple rows

2013-03-13 Thread Ananda Kumar
this is the data i tested on AIDQID ANS SCRID ATIMESTAMP -- -- -- -- --- 1 10 male3 13-MAR-13 02.03.20.00 PM 2 10

Re: Retrieve most recent of multiple rows

2013-03-13 Thread Ananda Kumar
select * from tab where anwer_timestamp in (select max(anwer_timestamp) from tab where q_id in (select distinct q_id from tab) group by q_id); On Wed, Mar 13, 2013 at 6:48 PM, Norah Jones nh.jone...@gmail.com wrote: I have a table which looks like this: answer_id q_id answer qscore_id

Re: Retrieve most recent of multiple rows

2013-03-13 Thread Ananda Kumar
can you please share the sql that you executed to fetch the above data On Wed, Mar 13, 2013 at 7:19 PM, Johan De Meersman vegiv...@tuxera.bewrote: - Original Message - From: Norah Jones nh.jone...@gmail.com Subject: Retrieve most recent of multiple rows 4 10

Re: Retrieve most recent of multiple rows

2013-03-13 Thread Johan De Meersman
- Original Message - From: Ananda Kumar anan...@gmail.com Subject: Re: Retrieve most recent of multiple rows select qid,max(atimestamp) from kkk where qid in (select distinct qid from kkk) group by qid; What use is that where statement? It just says to use all the rows in the table