I am trying to write a query that will total up the number of people on a particular course over and above a set age. For the example, the total number of students aged 19 and over. This is the query I have so far..
Select Sum(Case When date_of_birth Is Null Then 0 Else Floor(Months_Between(To_Date('3108' || Substr(Calocc_occurrence_code,1,2),'DDMMRR'),DATE_OF_BIRTH)/12) >19 End)) As 19
from people,registration_units,unit_instance_occurrences
Where people.person_code = registration_units.fes_per_person_code and registration_units.fes_unit_instance_code = Unit_instance_occurrences.fes_uins_instance_code and registration_units.uio_occurrence_code = unit_instance_occurrences.calocc_occurrence_code
group by fes_unit_instance_occurrences.fes_uins_instance_code
calocc_occurrence code displays the current academic year, so Substr(calocc_occurrence_code,1,2) would pull out 06. It is held within the database as 0607. The age function is calculating age as at the beginning of the academic year.
At the moment I am getting the following error;
ERROR at line 1:
ORA-00905: missing keyword
Is there something obvious that I have missed?
What I was hoping for was a course code followed by the number of 19+ people on the course
Can anyone help?
Select Sum(Case When date_of_birth Is Null Then 0 Else Floor(Months_Between(To_Date('3108' || Substr(Calocc_occurrence_code,1,2),'DDMMRR'),DATE_OF_BIRTH)/12) >19 End)) As 19
from people,registration_units,unit_instance_occurrences
Where people.person_code = registration_units.fes_per_person_code and registration_units.fes_unit_instance_code = Unit_instance_occurrences.fes_uins_instance_code and registration_units.uio_occurrence_code = unit_instance_occurrences.calocc_occurrence_code
group by fes_unit_instance_occurrences.fes_uins_instance_code
calocc_occurrence code displays the current academic year, so Substr(calocc_occurrence_code,1,2) would pull out 06. It is held within the database as 0607. The age function is calculating age as at the beginning of the academic year.
At the moment I am getting the following error;
ERROR at line 1:
ORA-00905: missing keyword
Is there something obvious that I have missed?
What I was hoping for was a course code followed by the number of 19+ people on the course
Can anyone help?