🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Same line SELECT MIN

#921
From: aleplgr
Date: Tue, 24 Apr 2007 11:35
44 lines
2029 bytes
Yes it's Interbase 7.5, sorry I posted here just a pseudocode, here's the code, now I get no error message but I'm not filtering the MIN DIFF, I'm getting all the patients, don't know why:

SELECT
t.PATIENTID,
t.DATE,
t.DIFF
FROM MYTABLE t
WHERE
t.DIFF = (SELECT MIN(q.DIFF) FROM 
MYTABLE q
WHERE t.PATIENTID = q.PATIENTID AND t.DATE = q.DATE)





"Karol Bieniaszewski" <liviuslivius@poczta.onet.pl> wrote:
>
>U�ytkownik "aleplgr" <aleplgr@yahoo.es> napisa� w wiadomo�ci 
>news:462dca7d$1@newsgroups.borland.com...
>>
>> Hi, I have this problem: my  table is
>> 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 )
>>
>
>Is this Interbase?
>In Interbase alias is after table name.
>And what errror do you get?
>
>Karol Bieniaszewski 
>
>
Technical Details
Message-ID: <462deb8f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <462dca7d$1@newsgroups.borland.com> <462dddcb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,67140aa9ee91b46d
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII
From: "aleplgr" <aleplgr@yahoo.es>
Sender: "aleplgr" <aleplgr@yahoo.es>
Reply-To: "aleplgr" <aleplgr@yahoo.es>
Subject: Re: Same line SELECT MIN
Newsgroups: borland.public.interbase.sql
X-User-Info: 80.58.205.38     
X-Forwarded-For: 80.25.195.180, 192.168.1.66
References: <462dca7d$1@newsgroups.borland.com> <462dddcb$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <462deb8f$1@newsgroups.borland.com>
Date: 24 Apr 2007 04:35:43 -0700
X-Trace: newsgroups.borland.com 1177414543 207.105.83.66 (24 Apr 2007 04:35:43 -0700)
Lines: 45
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail