Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query design

Author  Topic 

1sabine8
Posting Yak Master

130 Posts

Posted - 2010-01-25 : 05:02:38
Hi,
I need some help in a query i'm trying to build.
I have table customers and table tickets linked by the customer id and each customer can have many tickets.
In the table ticket we have the date the customer bought the ticket.
I need to have as result of my query the last date (most recent date) each customer bought a ticket.
EX: Customer A 1-1-2010
Customer B 3-1-2010
How can this be done?
thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-25 : 05:29:26
SELECT Customer, MAX(OrderDate) AS RecentDate
FROM Table1
GROUP BY Customer



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -