--分栏目统计今日更新软件数
select classid,今日更新=count(1) from article where datediff(day,dateandtime,getdate())=1 and classid in (select classid from f_news_getchildclass(208)) group by classidclassid 今日更新
209 186
210 331
211 18
214 10
215 118
217 48
218 269
219 27
220 190
我还想增加一列叫做 [软件总数],就是那个分类的软件总数,我不知道怎么写,既能按当日这个条件汇总出今日更新,又能不要这个条件汇总数软件总数
classid 今日更新 [软件总数]
209 186
210 331
211 18
214 10
215 118
217 48
218 269
219 27
220 190
select classid,今日更新=count(1) from article where datediff(day,dateandtime,getdate())=1 and classid in (select classid from f_news_getchildclass(208)) group by classidclassid 今日更新
209 186
210 331
211 18
214 10
215 118
217 48
218 269
219 27
220 190
我还想增加一列叫做 [软件总数],就是那个分类的软件总数,我不知道怎么写,既能按当日这个条件汇总出今日更新,又能不要这个条件汇总数软件总数
classid 今日更新 [软件总数]
209 186
210 331
211 18
214 10
215 118
217 48
218 269
219 27
220 190
解决方案 »
- 求个sql语句,达人来~~~
- 让哥蛋疼的cast函数
- 怎么让SQL查询分析器定时执行指定的命令
- 如何进入 mysql-front啊 ,怎么进不去
- 在将 nvarchar 值 '0_50' 转换成数据类型 int 时失败
- !批量插入数据的重复问题
- 为什么SQL Server2005安装一半后,停电了,在安装装就安不上了,怎么解决呀?(在线等.....急)
- 哪里有专门介绍InstallShield的书籍下载???请高人指路!!不胜感激!
- 在A字段相同的前提下把B字段内的字符串连接起来,用一个SQL语句写出来。
- MSSQL 数据表 删除记录然后添加记录 表的大小,和数据大小的变化
- sqlserver 如何得到最后一次 insert 操作得到的 自增类型的 ID
- 请问,修改表名字的SQL语句怎么写啊?
http://community.csdn.net/Expert/topic/5366/5366154.xml?temp=.8335382
搜集另类的sql语句集合
classid,
今日更新=count(1),
软件总数 = (Select Count(*) From article Where classid = A.classid)
from article A
where datediff(day,dateandtime,getdate())=1
and classid in (select classid from f_news_getchildclass(208))
group by classid
classid,
今日更新 = SUM(Case When datediff(day,dateandtime,getdate())=1 Then 1 Else 0 End),
软件总数 = Count(*)
From article A
Where classid in (select classid from f_news_getchildclass(208))
Group by classid
select
classid,
软件总数=count(1),
今日更新 = (Select Count(*) From article Where classid = A.classid and datediff(day,dateandtime,getdate())=1)
from article A
where
classid in (select classid from f_news_getchildclass(208))
group by classid