[英]SQL query for dataset in SSRS
I put two parameters in a query; 我在查询中放入了两个参数; [A_from] and [A_to] to decide some value in table for data set. [A_from]和[A_to]决定表中数据集的某个值。
The both of parameters allow Null/empty and the value changes by parameter as you can see below. 这两个参数都允许为Null / empty,并且值将根据参数而变化,如下所示。 How can I write query for this? 如何为此编写查询? (Tried case statement, but doesn't work..) (已尝试使用案例陈述,但无效。)
Input) Output)
A_From and A_To some Value Between A_From And A_To
Only A_From some value >= A_From
Only A_To some value <= A_To
Both NULL * (all)
Since comparisons to null
always yield false
, you can use this: 由于与null
比较总是产生false
,因此可以使用以下方法:
select *
from my_table t
where
(t.value >= A_From and t.value <= A_To) or
(t.value >= A_From and A_To is null) or
(A_From is null and t.value <= A_To) or
(A_From is null and A_to is null)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.