dimanche 21 décembre 2014

How to Select the First (or last) entry for a specific day


I have a table "AttendanceRecords" with entries like this



EntryID UUID PRIMARY KEY,
StafID UUID REFERENCES staffmembers(ID) NOT NULL,
ArrivalTime TIMESTAMP NOT NULL,
DepartureTime TIMESTAMP


For one function I want to find the first and last entry for a specified staff member on a specified date.


On a related report I would like to find all the entries where the arrival-times are on a specified date, eg sorted by StaffID


What would the queries look like for these (Using Postgres 9.3)





Aucun commentaire:

Enregistrer un commentaire