Reputation: 41
I have order table which has information about all the customers orders. Now, I want to pull the first orderdate and last orderdate of the each and every customer.
Can someone help me in this?
Thanks in Advance..
Upvotes: 0
Views: 46
Reputation: 70638
This is a simple MIN
and MAX
:
SELECT CustomerId,
MIN(OrderDate) Min_Order_Date
MAX(OrderDate) Last_Order_Date
FROM dbo.Orders
GROUP BY CustomerId;
Upvotes: 3