我数据库表contents里有color (varchar)和publishdate(datetime)两个字段
现在需要查询并显示两个星期之内的color字段设为红色(color='red')根据publishdate字段与当前日期比较(publishdate>getdate()-14)
而两个星期之前的color原本输出显示,不改变表里的数据,只根据条件改变显示的数据
我的语句是这样的
select (case when publishdate>getdate()-14 then color when publishdate <getdate()-14 then color end) as color,
publishdate from contents
如果case when then 里边用color='red' 会提示等号错误
大哥们帮帮忙,谢谢了
解决方案 »
- jquery URL传值为什么 有时候会出现乱码?
- grid extjs 显示缩略图
- DropDownList联动问题
- table复制row的问题
- 请教Web场中关于StateServer的问题
- 想网易新闻,新郎新闻一样,文章中间放置的广告怎么实现 有想法都说一下
- 我在C#中using Microsft.Xml.XQuery,请问在哪里能download到Microsoft的XQuery类库 ????急用!!
- 有关DataGrid的小问题!
- 在Web上打开和创建Word文件时出现接口失败?!
- 有谁知道,在Datagrid中,我明明要删除第二页的第一条数据,但为何...
- 点击率的效果
- 服务器端控件 asp:Repeater
2.case when (a<b) then ''
when (b<c) then '' end as 字段名
select
(case when publishdate > getdate()-14 then 'Red'
else color
end) as color
publishdate from contents