aspose file tools*
The moose likes JDBC 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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
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: 590


Product
ProductID ProductName

Customer
CustomerID FirstName LastName

Orders
OrderID, CustomerID

Order Details
OrderDetailID OrderID ProductID
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590

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: 3610
    
  60

Just adding p.ProductName and o.PurchaseDateTime to you GROUP BY clause might work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get the last purchased product?