Obtaining one value per person from table (“latest-n-per-group before cutoff date”)
问题 In a database of mine there is a table called 'Budget' defined as follows CREATE TABLE BUDGET ( ID INTEGER NOT NULL, THERAPIST INTEGER, CURDATE DATE, ILLNESS SMALLINT, HOLIDAY SMALLINT); ALTER TABLE BUDGET ADD PRIMARY KEY (ID); The purpose of the table is to store how many hours a month a therapist is entitled to sick leave and regular holiday. The table has the following values ID: 1, THERAPIST: 36, CURDATE: 01/01/2012, ILLNESS:8, HOLIDAY: 8 ID: 2, THERAPIST: 36, CURDATE: 01/07/2012, ILLNESS