繁体   English   中英

将条件提示添加到基于Cognos 10 sql的查询中

[英]adding conditional prompt to Cognos 10 sql based query

Cognos BI版本:10.2.2使用Report Studio
我有一个带有提示p1的报告,它是一个基于sql查询的报告。
提示用户界面:p1是一个DropdownList(使用值,显示值)
1全部,2值2、3值3、4值3

我正在尝试在SQL查询中添加基于条件的提示语法。

select col1, col2, col3, col4 from table1
where col4  is not null
case when #Prompt('p1')# = 1 then ' and 1=1'
     when #Prompt('p1')# = 2 then ' and col1 is null and col2 is not null'
     when #Prompt('p1')# = 3 then ' and col1 is not null and col2 is null'
     when #Prompt('p1')# = 4 then ' and col1 is null and col2 is null'
end

我尝试使用许多在线语法搜索,但是找不到有关我的场景的示例。 我需要帮助以正确的方式编写语句以满足我的要求。感谢您的帮助。

通常我建议您发布错误,但是这个错误似乎很明显

select col1, col2, col3, col4 from table1
where col4  is not null
and (
(#Prompt('p1','token','0')# = 1) OR
(#Prompt('p1','token','0')# = 2 and col1 is null and col2 is not null) OR
(#Prompt('p1','token','0')# = 3 and col1 is not null and col2 is null) OR
(#Prompt('p1','token','0')# = 4 and col1 is null and col2 is null)
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM