🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #349

Delete min does not work

#349
From: Alejandro
Date: Wed, 19 Mar 2008 14:48
24 lines
1508 bytes
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 for selecting the minimun date for each patient this SQL works fine:

SELECT T.NUMPAT,T.TREATMEN T,T.DATE
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )
order by T.NUMPAT

But for deleting the minimum date for each patient I'm trying this:
DELETE 
FROM MYTABLE T
WHERE
T.DATE=
(SELECT MIN(Q.DATE) FROM
MYTABLE Q WHERE T.NUMPAT = Q.NUMPAT )

But deletes the whole table, I don't know why..
Technical Details
Message-ID: <47e127be$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,a87d74dec5eac2,start
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alejandro" <aleplgr@yahoo.es>
Sender: "Alejandro" <aleplgr@yahoo.es>
Reply-To: "Alejandro" <aleplgr@yahoo.es>
Subject: Delete min does not work
Newsgroups: borland.public.interbase.sql
X-User-Info: 80.58.205.32     
X-Forwarded-For: 80.25.195.180, 192.168.1.66
NNTP-Posting-Host: 207.105.83.66
Message-ID: <47e127be$1@newsgroups.borland.com>
Date: 19 Mar 2008 07:48:30 -0700
X-Trace: newsgroups.borland.com 1205938110 207.105.83.66 (19 Mar 2008 07:48:30 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail