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?
Printable View
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?
Hope that it helps.Code:SELECT * FROM Patients where ADD_MONTHS(DOB,12*18)>SYSDATE
Actually should be
SELECT * FROM Patients where ADD_MONTHS(DOB,12*18)>=SYSDATE
Actually not necessery:rolleyes: .Quote:
Actually should be
antares686:Code:SELECT * FROM Patients WHERE ADD_MONTHS(DOB,216)>=TRUNC(SYSDATE)
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 :D.