my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes How to get the last purchased product? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to get the last purchased product?" Watch "How to get the last purchased product?" New topic
Author

How to get the last purchased product?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 634


Product
ProductID ProductName

Customer
CustomerID FirstName LastName

Orders
OrderID, CustomerID

Order Details
OrderDetailID OrderID ProductID
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 634

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

Joined: Aug 22, 2010
Posts: 3719
    
  61

Just adding p.ProductName and o.PurchaseDateTime to you GROUP BY clause might work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the last purchased product?
 
It's not a secret anymore!