gpt4 book ai didi

mysql - 如何将这两个查询合并为一个。?

转载 作者:行者123 更新时间:2023-11-30 23:25:00 25 4
gpt4 key购买 nike

这是我的两个查询 当我分别解雇他们时我给出了正确的答复但是当合并时他们不给出相同的答复。请帮助将它们组合起来

SELECT SUM(hours) AS S1
,operating_company
FROM Hours WHERE operating_company='AP-OH' GROUP BY operating_company

SELECT COUNT(*) AS S1,event_type
,operating_company
FROM Event WHERE operating_company='AP-OH' AND event_type='OSH Restricted' GROUP BY
operating_company,event_type

谢谢拉杰什B

最佳答案

你可以这样做:

SELECT
e.event_type,
e.operating_company,
SUM(h.hours) AS S1,
COUNT(e.*) AS S2
FROM Hours h
INNER JOIN event e ON h.operating_company = e.operating_company
WHERE h.operating_company = 'AP-OH'
AND e.event_type = 'OSH Restricted'
GROUP BY e.operating_company, e.event_type;

关于mysql - 如何将这两个查询合并为一个。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13796794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com