sql统计论坛每个版块今天帖子总数

来源:百度知道 编辑:UC知道 时间:2024/06/16 00:42:29
select count(p.fid),p.fid,f.name from cdb_posts as p,cdb_forums as f where f.fid=p.fid and p.fid in (SELECT fid FROM cdb_forums where fup=114 and status=1) and (UNIX_TIMESTAMP(NOW()) - p.dateline)/3600 < 24 GROUP BY p.fid
只能统计出不为0的版块,我想把为0的版块也输出,请问怎么写?
dz论坛的数据库,大家应该很熟悉。 只能统计出帖子数不为0的版块。

select sum(case when isnull(p.fid,0)=0 then 0 else 1 end),f.fid,f.name from cdb_forums f
left join cdb_posts p on f.fid=p.fid and f.fup=114 and f.status=1 and (UNIX_TIMESTAMP(NOW()) - p.dateline)/3600 < 24 GROUP BY f.fid
还是不对,提示:
MySQL Query : select sum(case when isnull(p.fid,0)=0 then 0 else 1 end),f.fid,f.name from cdb_forums f left join cdb_posts p on f.fid=p.fid and f.fup=114 and f.status=1 and (UNIX_TIMESTAMP(now()) - p.dateline)/3600 < 24 GROUP BY f.fid
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0)=0 then 0 else 1 end),f.fid,f.nam

额 少了点
select sum(case when isnull(p.fid,0)=0 then 0 else 1 end),f.fid,f.name from cdb_forums f
left join cdb_posts p on f.fid=p.fid and f.fup=114 and f.status=1 and (UNIX_TIMESTAMP(now()) - p.dateline)/3600 < 24
GROUP BY f.fid,f.name

只能统计出不为0的版块,我想把为0的版块也输出
什么为0的?哪个条件啊。
dz论坛的数据库,大家应该很熟悉 ???
不好意思,不知道、、、