Subject | delete min |
---|---|
Author | Alejandro Garcia |
Post date | 2008-03-19T10:12:03Z |
Hi! I have a patient's table with 3 fields:
NUMPAT is the number of the patient
TREATMENT is a treatment code
DATE a date
There are many dates for each patient and I need to select the minimun date for each patient. This SQL works fine:
SELECT T.NUMPAT,T.TREATMENT,T.DATE
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )
order by T.NUMPAT
By now I need to delete that minimun date for each patient, and simply change the first SELECT for a DELETE is not working... how could I?
Sorry for this so simple question...
---------------------------------
Enviado desde Correo Yahoo!
Disfruta de una bandeja de entrada más inteligente..
[Non-text portions of this message have been removed]
NUMPAT is the number of the patient
TREATMENT is a treatment code
DATE a date
There are many dates for each patient and I need to select the minimun date for each patient. This SQL works fine:
SELECT T.NUMPAT,T.TREATMENT,T.DATE
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )
order by T.NUMPAT
By now I need to delete that minimun date for each patient, and simply change the first SELECT for a DELETE is not working... how could I?
Sorry for this so simple question...
---------------------------------
Enviado desde Correo Yahoo!
Disfruta de una bandeja de entrada más inteligente..
[Non-text portions of this message have been removed]