Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table appointments
- (
- id serial not null constraint appointments_pkey primary key,
- patient_id varchar(255) not null,
- date timestamp(0) not null
- );
- SELECT
- (
- SELECT MIN(ap.date) FROM appointments ap
- WHERE ap.date >= NOW() AND ap.patient_id = '1'
- ) AS next,
- (
- SELECT MAX(ap.date) FROM appointments ap
- WHERE ap.date < NOW() AND ap.patient_id = '1'
- ) AS last
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement