MySQL Forums
Forum List  »  MySQL Query Browser

Return Last Row by Each ContactID
Posted by: Paul Henderson
Date: January 16, 2013 03:08AM

Hi All,

I dont know if this is possible.
I am trying to run a query that will show me the last row in a table for each individual contactid in a given account.

something like:
SELECT contacitd, completeddate FROM activities where accountid = 'AAXA-SZMY8K' ORDER BY contactid DESC LIMIT 10;

The problem is i dont always know how many contactid's will be in a given accountid, so the DESC LIMIT 10 wont work for me.
Also, the above query returns the last 10 rows of a given accountid regardless of contactid, so it usually returns the last 10 rows for a single contactid rather than show the time/date of the last activity for each contactid.

Im running this to export to a csv file, so any suggestions would be welcome.


Options: ReplyQuote

Written By
Return Last Row by Each ContactID
January 16, 2013 03:08AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.