将参数添加到 SQL select 并在 Cognos Report Studio 版本 10.2.1 中使用它们
Adding parameters to SQL select and using them in Cognos Report Studio Version 10.2.1
我正在尝试将 select 日期参数放入我的 select 中。我不确定该怎么做。现在我有固定的日期值,现在我想要一个参数,如:StartDate 和 EndDate。
如果有任何帮助,我将不胜感激。
我的 select:
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
宏提示语法是#prompt('StartDate','date')# 这会将您的SQL更改为:
select劳动法,
(select sum(workhours) from workperiod where calnum='KOPA'and workdate between to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) -
(select count(calnum) from workperiod where calnum='KOPA'and workdate between to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY') 和 shiftnum='HOLIDAY') * 8 作为 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( #prompt('StartDate','date')#,'DD.MM.YYYY') 和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) 作为 delovne_ure,
(select sum(ass.laborhrs) from assignment ass where ass.laborcode = l.laborcode and ass.scheduledate between to_date(#prompt('StartDate' ,'date')#,'DD.MM.YYYY') 和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) 作为 assignment_ure
来自劳动力 l
我正在尝试将 select 日期参数放入我的 select 中。我不确定该怎么做。现在我有固定的日期值,现在我想要一个参数,如:StartDate 和 EndDate。 如果有任何帮助,我将不胜感激。 我的 select:
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
宏提示语法是#prompt('StartDate','date')# 这会将您的SQL更改为:
select劳动法,
(select sum(workhours) from workperiod where calnum='KOPA'and workdate between to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) -
(select count(calnum) from workperiod where calnum='KOPA'and workdate between to_date(#prompt('StartDate','date')#,'DD.MM.YYYY')和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY') 和 shiftnum='HOLIDAY') * 8 作为 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( #prompt('StartDate','date')#,'DD.MM.YYYY') 和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) 作为 delovne_ure,
(select sum(ass.laborhrs) from assignment ass where ass.laborcode = l.laborcode and ass.scheduledate between to_date(#prompt('StartDate' ,'date')#,'DD.MM.YYYY') 和 to_date(#prompt('EndDate','date')#,'DD.MM.YYYY')) 作为 assignment_ure
来自劳动力 l