关于sql语句sum查询的经典分析
答案:2 悬赏:30 手机版
解决时间 2021-11-26 22:19
- 提问者网友:浮克旳回音
- 2021-11-26 07:45
关于sql语句sum查询的经典分析
最佳答案
- 五星知识达人网友:夜余生
- 2021-11-26 08:43
--sql:
SELECt
sum((case when address.id is not null then 1 else 0 end)) num,
art.id,
art.admin_id kehu_id,
art.news_title ,
address.id addrid,
address.admin_id,
admin.change_time
FROM tb_news_article art
LEFT JOIN tb_news_article_address address ON art.id = address.news_article_id
LEFT JOIN tb_admin_news admin ON art.id = admin.news_article_id
WHERe (admin.admin_id = 45)
GROUP BY art.id
having num>5
SELECt
sum((case when address.id is not null then 1 else 0 end)) num,
art.id,
art.admin_id kehu_id,
art.news_title ,
address.id addrid,
address.admin_id,
admin.change_time
FROM tb_news_article art
LEFT JOIN tb_news_article_address address ON art.id = address.news_article_id
LEFT JOIN tb_admin_news admin ON art.id = admin.news_article_id
WHERe (admin.admin_id = 45)
GROUP BY art.id
having num>5
全部回答
- 1楼网友:忘川信使
- 2021-11-26 10:12
最后加上:
HAVINg num > 5我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯