首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

容易sql语句

2013-02-24 
简单sql语句comment表id newId commenttext isDelete12aaaaa022bbbbb032ccccc042ddddd1 53fffff0查出newId

简单sql语句
comment表
id newId commenttext isDelete
1   2     aaaaa         0
2   2     bbbbb         0
3   2     ccccc         0
4   2     ddddd         1 
5   3     fffff         0
查出newId=2  一共回复数和不包含删除的回复数

newid replycount replycountall
2         3          4
[解决办法]
select [newId],replycount =sum(case when isDelete=1 then 0 else 1 end),count(1) replycountall from tb

热点排行