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
 SQL Server Development (2000)
 query--Critical problem

Author  Topic 

Shumaila
Starting Member

21 Posts

Posted - 2001-10-18 : 17:41:22
Now i have got a very strange kind of problem. Every time i think about it it looks like i have got the solution but then it skips. Lets see how you people would do it.

There is a table which have customer order records with fields

Order_id, Customer_id, Product_id, DateTimeOrdered

Order_id is unique. Customers are ordering the products and the datetime of the order is recorded. Now Customer C1 could have ordered Product P1 many times but the id and datetime would be different. So the sample date could be
ID Cust Produt DateTime
1 C1 P1 10/18/00..
2 C2 P2 7/18/00..
3 C1 P3 10/8/00..
4 C1 P1 02/1/01..
5 C2 P3 10/18/01..

I have to pick latest ordered for each product booked by each customer. I have to pick whole row (all 4 fields... there could be more). This means i have to group by customer and Product (or something like that) to check for the date (max(date)).
   

- Advertisement -