我试着在我的select中放入一个日期参数。我不知道如何才能真正做到这一点。现在我有固定的日期值,现在我想有一个参数,如:StartDate和EndDate。我将非常感谢任何帮助。我的选择:
select laborcode,
(select sum(workhours) from workperiod where calnum='...'and workdate between to_date('01.02.2020','DD.MM.YYYY') and to_date('01.03.2020','DD.MM.YYYY')) -
(select count(calnum) from workperiod where calnum='...'and workdate between to_date('01.02.2020','DD.MM.YYYY') and to_date('01.03.2020','DD.MM.YYYY') and shiftnum='HOLIDAY') * 8 as alias,
(select sum(lt.regularhrs) from labtrans lt where lt.laborcode = l.laborcode and lt.orgid = l.orgid and startdate between to_date('01.02.2020','DD.MM.YYYY') and to_date('01.03.2020','DD.MM.YYYY')) as alias,
(select sum(ass.laborhrs) from assignment ass where ass.laborcode = l.laborcode and ass.scheduledate between to_date('01.02.2020','DD.MM.YYYY') and to_date('01.03.2020','DD.MM.YYYY')) as alias
from labor l
1条答案
按热度按时间42fyovps1#
宏提示符语法为#prompt('StartDate','date')#,它会将您的SQL更改为:
选择劳动力代码,(从工作期间中选择总计(工作小时数),其中calnum ='KOPA',工作日期介于to_date(#prompt('StartDate','date')#,'DD.MM. YYYY')和to_date(#prompt('EndDate','date')#,'DD.MM. YYYY')之间)-
(从工作周期中选择计数(计算值),其中计算值=“KOPA”,工作日期介于至日期(#prompt(“开始日期”,“日期”)#,“DD.MM. YYYY”)和至日期(#prompt(“结束日期”,“日期”)#,“DD.MM. YYYY”)之间,班次数=“HOLIDAY”)* 8作为stevilo_praznikov_ure,(从实验室事务lt中选择合计(lt.常规小时数),其中lt.实验室代码= l.实验室代码,lt.组织标识= l.组织标识,起始日期介于to_date(#prompt('起始日期','日期')#,'DD.MM. YYYY')和至日期(#prompt('EndDate','date')#,'DD.MM. YYYY'))作为分配,(从分配分配中选择总计(分配人工小时数),其中分配人工代码= 1.人工代码,分配计划日期介于至日期(#prompt('StartDate','date')#,'DD.MM. YYYY')和至日期(#prompt('EndDate','date')#,'DD.MM. YYYY'))之间,作为分配人工代码