If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Min(date)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-02-11, 10:48
brucezepplin brucezepplin is offline
Registered User
 
Join Date: Jul 2011
Posts: 19
Min(date)

Hi, I have a database with user defined dates in it for when a person has gone into hospital (admis_date). What I am looking to do is to find the first time a person was admitted to hospital only. ie if a person has attended a clinic for influenza 5 times in their life, i only want to pick out the first time. I have

Code:
SELECT DISTINCT Person, MIN(Admis_Date) AS FIRST_DATE, Diagnosis
FROM DATABASE A
WHERE Diagnosis = "influenza"
but this returns all instances of influenza for everyone in the database. Whats going on?
Reply With Quote
  #2 (permalink)  
Old 08-02-11, 11:00
brucezepplin brucezepplin is offline
Registered User
 
Join Date: Jul 2011
Posts: 19
it's ok i;ve fixed it.
Reply With Quote
  #3 (permalink)  
Old 08-02-11, 11:41
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
How? Would you mind sharing the solution

----
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On