|
-
May 4th, 2005, 12:08 PM
#1
oracle query help
Patient table:
Patient Number Name DOB
--------- ------------- -----------
P32423 Joe bloggs 4-feb-78
P11123 Katy smith 6-jun-97
P03923 Jacob halls 16-dec
need a query to display patients that are under 18. any help?
-
May 5th, 2005, 09:11 AM
#2
Re: oracle query help
Code:
SELECT * FROM Patients where ADD_MONTHS(DOB,12*18)>SYSDATE
Hope that it helps.
-
May 5th, 2005, 01:24 PM
#3
Re: oracle query help
Actually should be
SELECT * FROM Patients where ADD_MONTHS(DOB,12*18)>=SYSDATE
-
May 5th, 2005, 03:06 PM
#4
Re: oracle query help
Actually not necessery .
-
May 6th, 2005, 02:52 AM
#5
Re: oracle query help
Code:
SELECT * FROM Patients WHERE ADD_MONTHS(DOB,216)>=TRUNC(SYSDATE)
antares686:
your solution makes no important difference .
It is common error made by begginers - SYSDATE contains hour, minute etc. and date of birth usually NOT.
And it depends on customs/regional rules if man in date of his birth is considered that he is under age or not (it is often stated that he have to has finished 18 years - that he has to be 18+)
Hope U understand what I wrote .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|