Subject | Re: [firebird-support] SELECT MIN |
---|---|
Author | Helen Borrie |
Post date | 2007-04-24T09:23:58Z |
At 07:12 PM 24/04/2007, you wrote:
of table aliasing yet! ;-)
SELECT
t.PATIENTID,
t.fecha
t.,DIFF
FROM MYTABLE t
WHERE
t.DIFF = (SELECT MIN(q.DIFF) FROM MYTABLE q
WHERE t.PATIENTID = q.PATIENTID
AND t.fecha = q.fecha )
./heLen
>Hi, I have this problem: my table isNo, it wouldn't be working. I don't think you quite have the "hang"
>PATIENTID, DATE, DIFF
>
>for each PATIENTID can be many DATE and many DIFF, DIFF is an
>integer and I need for each PATIENTID the MIN DIFF and the DATE of
>the same line where MIN(DIFF) is.
>
> I did this: but it's not working
>
> SELECT PATIENTID,DATE,DIFF FROM T MYTABLE
> WHERE DIFF = (SELECT MIN(DIFF) FROM Q MYTABLE
> WHERE (T.PATIENTID = Q.PATIENTID
> AND T.DATE = Q.DATE )
of table aliasing yet! ;-)
SELECT
t.PATIENTID,
t.fecha
t.,DIFF
FROM MYTABLE t
WHERE
t.DIFF = (SELECT MIN(q.DIFF) FROM MYTABLE q
WHERE t.PATIENTID = q.PATIENTID
AND t.fecha = q.fecha )
./heLen