Extracting Month from a Date. Oracle SQL.
I have an employee table and need to find the total hiring done for each month & display result in ascending order of months.
Points to focus:
- extract month.
- convert character formatted date to date type.
- group by extracted month.
- apply count.
select
extract (month from (to_date(hire_date,'mm dd yyyy'))) as "Month",
count(*) as "Total Hiring"
from employees
group by extract (month from (to_date(hire_date,'mm dd yyyy')))
order by "Month";
PIS: what if I want to see employees hired within the first half of any month?
Please be in touch with me for the solution.
Comments
Post a Comment