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:
how go selecting first booking of each vehicle?
i ended using query had select of bookings vehicle , removed bookings of later date in ejb.