java - Select first booking of each vehicle in JPQL -


i'm trying select first booking of each vehicle having difficulties. query have is

@namedquery(name = "findbookingbyvehicle", query = "select c.colour, c.seats, c.make, c.model, b.departuredate, b.returndate, b.bookingdate, e.fname, e.lname vehicle c join c.booking b join b.employee e c = b.vehicle , b.employee = e order b.bookingdate, b.departuredate ") 

but selects of bookings of each vehicle.

my table structure is:

table picture

how go selecting first booking of each vehicle?

i ended using query had select of bookings vehicle , removed bookings of later date in ejb.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo