关于sql语句sum查询的经典分析
在写好的sql语句里该怎么添加条件:sql:SELECTsum((casewhenaddress.idisnotnullthen1else0end))num,art.id...
在写好的sql语句里该怎么添加条件:
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 展开
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 展开
2个回答
展开全部
--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
ZESTRON
2024-09-04 广告
2024-09-04 广告
表面污染分析包括评估表面上存在的颗粒、残留物或物质。通过利用显微镜、光谱学和色谱法等技术,分析人员可以识别和表征污染物,以确定其成分和来源。这种分析在电子、制药和制造等各个行业中至关重要,以确保产品质量、性能和安全性。了解表面污染有助于实施...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |