将不符合要求的数据隐藏
数据库:
ID	CD1	CD2	CD3
1	2012-10-1	2012-10-10	2012-10-20
2	2012-11-1	2012-11-10	2012-10-13
3	2012-12-1	2012-10-6	2012-11-14
想要得到的结果:
ID	CD1	CD2	CD3
1	2012-10-1	2012-10-10	2012-10-20
2	2012-11-1		2012-10-13
3		2012-10-6	
简单来说,就是CD1、CD2、CD3字段中,范围在2012-10-1到2012-11-1之间。一般的SELECT会全部显示出来,有没有方法可以把那些不符合这个范围之内的数据隐藏?或者用其它字符来代替?
------最佳解决方案--------------------select id,
(case when cd1 between '2012-10-1' and '2012-11-1' then convert(varchar(10),cd1,120 else '' end) as cd1,
(case when cd2 between '2012-10-1' and '2012-11-1' then convert(varchar(10),cd2,120 else '' end) as cd2,
(case when cd3 between '2012-10-1' and '2012-11-1' then convert(varchar(10),cd3,120 else '' end) as cd3
from tb
如果要显示其他字符,则用这些字符代替上面的''.
------其他解决方案--------------------case when then
------其他解决方案--------------------实在是多谢了!