我正在尝试在选择日期参数中添加一个。我不确定如何真正做到这一点。现在,我有固定的日期值,现在我想要一个像StartDate和EndDate这样的参数。我将非常感谢您的帮助。我的选择:
select laborcode,
(select sum(workhours) from workperiod where calnum='KOPA'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='KOPA'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 stevilo_praznikov_ure,
(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 delovne_ure,
(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 assignment_ure
from labor l
宏提示语法为#prompt('StartDate','date')#,这会将您的SQL更改为:
选择人工代码,(从calnum ='KOPA'的工作期间中选择总和(workhours),在to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和to_date(#prompt('EndDate', 'date')#,'DD.MM.YYYY'))-(从calnum ='KOPA'的工作期间中选择count(calnum),在to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和to_date(#prompt('EndDate', 'date')#,'DD.MM.YYYY')和shiftnum ='HOLIDAY')* 8为stevilo_praznikov_ure,(请从labtrans lt中选择sum(lt.regularhrs),其中lt.laborcode = l.laborcode和lt.orgid = l.orgid,以及介于to_date(#prompt('StartDate','date')#,'DD.MM之间的开始日期。 YYYY')和to_date(#prompt('EndDate','date')#,'DD.MM.YYYY'))作为delovne_ure,(从分配的驴子中选择sum(ass.laborhrs),其中ass.laborcode = l.laborcode和ass.scheduledate在to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和to_date( #prompt('EndDate','date')#,'DD.MM.YYYY'))作为Assignment_ure从劳l