Hi,
I have a table which have cust_id and product_id and order date.
Customer 1 can order product 1 many times only dateandtime would be different. I need to get the latest order for each (customer, product) combination
C1 ,p1 could have many rows i need only latest one. and same is true for c1, p2.... c2, p1...
I can't get the query straight.
So far i have come up with
select * from Order join
(select Customer_ID, Product_id , max(datetimestamp) as max_date
from Order
group by Customer_ID, Product_id) A
on Order.Customer_id = A.Customer_id and Order.Product_id = A.Product_id
This join query is giving all the records instead of the latest order
I have a table which have cust_id and product_id and order date.
Customer 1 can order product 1 many times only dateandtime would be different. I need to get the latest order for each (customer, product) combination
C1 ,p1 could have many rows i need only latest one. and same is true for c1, p2.... c2, p1...
I can't get the query straight.
So far i have come up with
select * from Order join
(select Customer_ID, Product_id , max(datetimestamp) as max_date
from Order
group by Customer_ID, Product_id) A
on Order.Customer_id = A.Customer_id and Order.Product_id = A.Product_id
This join query is giving all the records instead of the latest order