• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the last purchased product?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Product
ProductID ProductName

Customer
CustomerID FirstName LastName

Orders
OrderID, CustomerID

Order Details
OrderDetailID OrderID ProductID
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here is the most refined version, but I can't get repeated purchased items for each order.
There is only one order item listed.

I'd like to get
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just adding p.ProductName and o.PurchaseDateTime to you GROUP BY clause might work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic