小编Jan*_*Jan的帖子

在where子句中使用"If"条件

我喜欢在where子句中使用"IF"条件.从各种线程,我理解其中一个选项是CASE表达式,但我无法弄清楚.

示例代码:

select * from sampleTable
where 
  If @taxtype = 'P' then
    (taxtype = 'P' or  (taxtype = 'E' and code in ('MER','SER')))
  Else
    (taxtype = 'E' and code not in ('MER','SER'))
  End If
Run Code Online (Sandbox Code Playgroud)

任何帮助是极大的赞赏.

谢谢!

sql postgresql

2
推荐指数
1
解决办法
112
查看次数

标签 统计

postgresql ×1

sql ×1