Skip to content
Advertisement

How to use a calculated value in Oracle SQL count

I have a column called BIRTH_DATE in my view. I want to calculate the age using that column and today’s date, and count the number of staff in an age bracket. For example: staff between 40 and 49 etc.

Other answers in plain SQL statements are also welcome.

My code is shown below:

I am calculating the age as shown below:

After doing this if I try to access the TEACHING_COUNT variable in the model it is null.

Advertisement

Answer

You can count the number of records between an age bracket without needing to write any SQL as well.

Since you are already using yii, it seems to make sense to use its methods directly. In this case the count() method.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement