[thelist] SQL: Select first item for each person for each day

Judah McAuley judah at wiredotter.com
Tue Feb 24 13:20:34 CST 2009

I'm ill and having difficulty wrapping my head around an issue I know
I've done before, so I'm hoping that someone can help me out.

I have a table that lists patient's appointments.

appointment_date (datetime)

A patient can have 0...n appointments on any given day. What I need to
do right now is generate a view that lists only the first appointment
for each patient each day. I'm pretty sure I need to be grouping by a
day of year function on the appointment_date but my brain is kind of
losing it on the rest. DB server is Sql Server 2000.

Any thoughts?

Thanks in advance,

More information about the thelist mailing list