求一条SQL语句 分类统计

liu_GT 2010-03-24 09:32:49
有新闻表(news_content),字段:

news_id,

news_tile,

news_content,

news_addtime(datetime,如:2009-03-23 12:12:12 000),

news_ediror(编辑)

我想查询某编辑在本月每天添加的新闻数量,该怎么写,谢谢各位了。

就是这样的结果:

news_num news_addtime

12 2010-03-01

23 2010-03-02

... ...
...全文
67 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liu_GT 2010-03-24
  • 打赏
  • 举报
回复
谢谢楼上两位,在你们SQL语句的基础上我加了条件(限制在本月)
结果如下:

select count(1) as news_num,
convert(varchar(10),news_addtime,120) as news_addtime
from news_content
where news_ediror='编辑名称' and datediff(month,news_posttime,getdate())=0
group by convert(varchar(10),news_addtime,120)
order by news_addtime asc
永生天地 2010-03-24
  • 打赏
  • 举报
回复
select count(*) as  news_num ,
news_addtime
from news_content
where datediff(mm,news_addtime ,getdate())=0
and news_ediror=?
--小F-- 2010-03-24
  • 打赏
  • 举报
回复
select
count(1) as news_numm,
convert(varchar(10),news_addtime,120) as news_addtime
from
tb
group by
convert(varchar(10),news_addtime,120)
黄_瓜 2010-03-24
  • 打赏
  • 举报
回复
select count(1) as news_numm, 
convert(varchar(10),news_addtime,120) as news_addtime
from tb
group by convert(varchar(10),news_addtime,120)
liu_GT 2010-03-24
  • 打赏
  • 举报
回复
顶一下

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧