Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- https://pgexercises.com/questions/aggregates/nbooking.html
- with t1 as(
- select surname, firstname, m.memid, starttime
- from cd.members m
- join cd.bookings b
- on b.memid = m.memid
- where starttime::DATE >= '2012-09-01'
- group by 1,2,3,4 -- removing group by produces wrong data in the next step
- order by 3 asc
- )
- select distinct on (3) *
- from t1
Add Comment
Please, Sign In to add comment