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 2000 Forums
 Transact-SQL (2000)
 Need QUERY do to ....

Author  Topic 

regent
Starting Member

1 Post

Posted - 2003-06-15 : 22:26:36
Consider my table columns is "CUST_NO" and "PURCH_DATE" :

I need to compose a query wich retreive a list of custumers no but only one row per CUST_NO and I want to have the most recent PURCH_DATE.

THANKS !

Sample :

My table :

CUST_NO | PURCH_DATE
1 | 2001-02-14
2 | 2001-04-18
3 | 2002-02-14
2 | 2002-11-05
4 | 2003-08-27
1 | 2003-09-12

I want query to have this :

CUST_NO | PURCH_DATE
1 | 2003-09-12
2 | 2002-11-05
3 | 2002-02-14
4 | 2003-08-27

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-06-15 : 22:32:31
SELECT Cust_no, Max(Purch_Date) AS Purch_Date
FROM myTable
GROUP BY Cust_No


Go to Top of Page
   

- Advertisement -