作者jengting (~~)
看板Database
标题Re: [SQL ] 有关case when的两个问题
时间Sun May 26 08:03:44 2013
: 直接把case条件式写在where後试试
: select *
: from 资料表A as A join 资料表B as B on A.no = B.no
: where (case
: when B.redate is null then
: (case
: when B.des is null then
: A.opdate
: else
: B.opdate
: end)
: else
: B.redate
: end) = '2013/05/05';
建议不要在 WHERE 中去进行 CASE WHEN、IIF()、ISNULL() 或 COALESCE()
的动态筛选条件,会导致索引无法正常使用,造成效能问题。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.62.56.115