SELECT
employee_id x_employee_id,
min(schedule_date) x_schedule_begin_date,
max(schedule_date) x_schedule_end_date,
sum(case when product_uom.name='Day(s)' then leave_detail_view.duration when product_uom.name='Hour(s)' then leave_detail_view.duration/8.0 else 0 end) x_total_duration
FROM leave_detail_view
left join product_uom
on leave_detail_view.product_uom_id=product_uom.id
left join hr_holiday_type on leave_detail_view.leave_type=hr_holiday_type.id
where
to_char(leave_detail_view.schedule_date,'YYYY-MM')<=to_char(current_date::timestamp + '-1 month','YYYY-MM')
and to_char(current_date::timestamp + '-1 month','YYYY-MM')>= to_char(current_date::timestamp + '-6 month','YYYY-MM')
and
hr_holiday_type.code in ('L012','L007','L024','L012_In')
group by employee_id
having
sum(case when product_uom.name='Day(s)' then leave_detail_view.duration when product_uom.name='Hour(s)' then leave_detail_view.duration/8.0 else 0 end) >=125
sql:
SELECT
employee_id x_employee_id,
min(schedule_date) x_schedule_begin_date,
max(schedule_date) x_schedule_end_date,
sum(case when product_uom.name='Day(s)' then leave_detail_view.duration when product_uom.name='Hour(s)' then leave_detail_view.duration/8.0 else 0 end) x_total_duration
FROM leave_detail_view
left join product_uom
on leave_detail_view.product_uom_id=product_uom.id
left join hr_holiday_type on leave_detail_view.leave_type=hr_holiday_type.id
where
to_char(leave_detail_view.schedule_date,'YYYY-MM')<=to_char(current_date::timestamp + '-1 month','YYYY-MM')
and to_char(current_date::timestamp + '-1 month','YYYY-MM')>= to_char(current_date::timestamp + '-6 month','YYYY-MM')
and
hr_holiday_type.code in ('L012','L007','L024','L012_In')
group by employee_id
having
sum(case when product_uom.name='Day(s)' then leave_detail_view.duration when product_uom.name='Hour(s)' then leave_detail_view.duration/8.0 else 0 end) >=125