Culture Bunker forum


View latest messages in My Forums
This topic has been archived, and won't accept reply postings.

Topic - Bit of SQL help?

ThunderCat - on 24 Jan 2013
This is probably so easy I’m missing it.

Got this simple table. I want to pull back a single record for each of the four Customers showing their most recent appointment.

AppID CustID Name Date Value
1 1 Paul 01/01/2012 100
2 1 Paul 01/05/2012 200
3 1 Paul 01/01/2013 50
4 2 John 04/05/2012 100
5 2 John 05/08/2012 200
6 2 John 05/10/2012 300
7 3 George 02/03/2010 45
8 3 George 01/10/2012 45
9 3 George 01/02/2013 10
10 4 Ringo 05/06/2012 75
11 4 Ringo 05/07/2012 75
12 4 Ringo 01/11/2012 2

If it was only the AppID, CustID, Name and Date I could just aggregate them – GROUP the first three and MAX the date, the Value column throws a spanner in the works (and this is just a dumbed down example…my tables a lot more involved than this)

This is what I would want the output to be.

AppID CustID Name Date Value
3 1 Paul 01/01/2013 50
6 2 John 05/10/2012 300
9 3 George 01/02/2013 10
12 4 Ringo 01/11/2012 2

Is it doable?
... not showing 11 replies to this topic ...
Register as a New User or login to gain full access to the forums. Registration is quick and completely free.
If you are definitely logged on, press Ctrl+F5 keys to reload this page [read more]

Unregistered users can only read messages in the most recent topics.

This topic has been archived, and won't accept reply postings.

My Forums