mysql DISTINCT & ORDER BY

Post

Posted
Rating:
#1 (In Topic #176)
Regular
bill-lancaster is in the usergroup ‘Regular’
 I hope it's not a problem posting a mysql issue here!
I have a table 'transactions' with a number of fields including 'TransRef and TransDate).  I want to select 'TransRef' as DISTINCT and ORDER BY TransDate.
I've read a number of learned items on this but can't solve the problem.
For example, the table could look like this:-
TransRef         TransDate     otherfields
0123                 12/31/2017
0123                 12/31/2017
0144                 01/30/2017
0144                 01/30/2017
0110                 03/10/2017
0110                 03/10/2017

This is the result I'm seeking
0144                 01/30/2017
0110                 03/10/2017
0123                 12/31/2017
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
jornmo is in the usergroup ‘Regular’
This seems to work:

<HIGHLIGHT highlight="sql">SELECT DISTINCT TransRef, TransDate FROM Transactions ORDER BY TransDate;</HIGHLIGHT>

Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thank you so much.
I thought that was where I'd started - must have been mistaken
Thanks again
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Your very welcome.

Online now: No Back to the top
1 guest and 0 members have just viewed this.