02-25 7:00'
>> union all select 2, 'McSteamy', '2009-02-25 7:45'
>>
>> insert into @first_appointment_per_day
>> (patient_id, appointment_date)
>> (select patient_id, min(appointment_date)
>> from @appointment
>> group by patient_id, conv
-25 7:00'
> > union all select 2, 'McSteamy', '2009-02-25 7:45'
> >
> > insert into @first_appointment_per_day
> > (patient_id, appointment_date)
> > (select patient_id, min(appointment_date)
> > from @appointment
> > group by patient
t patient_id, min(appointment_date)
> from @appointment
> group by patient_id, convert(varchar(10), appointment_date, 101))
>
> select app.patient_id, app.appointment_date, app.doctor
> from @first_appointment_per_day tmp1
> inner join @appointment app on tmp1.patient_id = app.patient_id
&
This is the sort of approach I was trying to think of, couldn't
remember derived tables. This query only grabs the earliest
appointment for each patient though not the earliest for every day.
But it is a good starting point, I'll try to massage a group by date
in there and see what I can come up w
Maybe
Select top 1 * from appointment where appointment between (date/time and
date/time) order by appointment_date
Ben Conner wrote:
> Hi Judah,
>
> I suppose there's more than one way to do this, but this should work...
>
> SELECT a.*
> FROM appointment a INNER JOIN
>
Hi Judah,
I suppose there's more than one way to do this, but this should work...
SELECT a.*
FROM appointment a INNER JOIN
(SELECT patient_id, MIN(appointment_date)
AS appointment_date
FROM appointment
ointment_date)
from @appointment
group by patient_id, convert(varchar(10), appointment_date, 101))
select app.patient_id, app.appointment_date, app.doctor
from @first_appointment_per_day tmp1
inner join @appointment app on tmp1.patient_id = app.patient_id
and tmp1.appointment_date = app.appointment_date
~Brad
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
id
patient_id
doctor
appointment_date (datetime)
A patient can have 0...n appointments o
8 matches
Mail list logo