`SELECT * FROM [case]
WHERE status = '0'
and date_rec > '01 January 2012'
and 'ClientFilter' =
CASE @clientcode
WHEN '' THEN 'ClientFilter'
ELSE
CASE WHEN client in
(SELECT ID COLLATE DATABASE_DEFAULT FROM
GREEN.dbo.fnSplitter(@clientcode)) THEN 'ClientFilter' END END; `
我想在上面的查询中添加一个额外的过滤器,类似于 clientfilter。有谁知道如何做到这一点。例如应该如下但不起作用。
`SELECT * FROM [case]
WHERE status = '0'
and date_rec > '01 January 2012'
and 'ClientFilter' =
CASE @clientcode
WHEN '' THEN 'ClientFilter'
ELSE
CASE WHEN client in
(SELECT ID COLLATE DATABASE_DEFAULT FROM GREEN.dbo.fnSplitter (@clientcode))
THEN 'ClientFilter' END END;
and 'SchemeFilter' =
CASE @schemecode WHEN '' THEN 'SchemeFilter'
ELSE
CASE WHEN client in
(SELECT ID COLLATE DATABASE_DEFAULT FROM GREEN.dbo.fnSplitter(@schemecode))
THEN 'SchemeFilter' END END; `