Subject | Re: [firebird-support] delete min |
---|---|
Author | Kjell Rilbe |
Post date | 2008-03-19T20:12:40Z |
Alejandro Garcia wrote:
DELETE
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )
Note that the order by has been removed.
Why doesn't it work? What error do you get?
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> There are many dates for each patient and I need to select the minimunI would have expected this to work:
> 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...
DELETE
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )
Note that the order by has been removed.
Why doesn't it work? What error do you get?
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64