我有一个pay_time_period表,详细信息如下
PAYROLL_ID START_DATE END_DATE PERIOD_NUM
10 01-MAY-2023 10-MAY-2023 1
10 11-MAY-2023 18-MAY-2023 2
10 19-MAY-2023 25-MAY-2023 3
10 26-MAY-2023 05-JUN-2023 4
现在我需要找到参数date传递的月份中的期数。如何调整下面的查询
(select distinct
COUNT(ptp1.PERIOD_NUM) OVER (PARTITION BY ptp1.PAYROLL_ID,papf.person_number) period_count
from pay_time_periods ptp1
where ptp1.TIME_PERIOD_ID = ptp.TIME_PERIOD_ID
and :p_process_date between ptp1.start_Date and ptp1.end_date
)
结果应该是4。由于在5月份有4个period_num
2条答案
按热度按时间6mw9ycah1#
试试这个:
rdlzhqv92#