gpt4 book ai didi

mysql - 如何使用子选择?

转载 作者:行者123 更新时间:2023-11-29 18:21:41 25 4
gpt4 key购买 nike

如何使用 MySQL 中的子选择查询或任何其他方法重写此查询?
我使用 3 个表:

SELECT i.resp_id as id
, Count(1)
FROM int_result i
JOIN response_set rs on i.response_set_id = rs.id
JOIN cx_store_child cbu on rs.cx_business_unit_id = cbu.child_bu_id
AND cbu.business_unit_id = 30850
AND rs.survey_id IN (5550512,5550516,5550521,5550520,5590351,5590384,5679615,5679646,5691634,5699259,5699266,5699270)
AND i.q_id IN (52603091,52251250,52250724,52251333,52919541,52920117,54409178,54409806,54625102,54738933,54739117,54739221)
AND rs.t >= '2017-08-30 00:00:00'
AND rs.t <= '2017-09-30 00:00:00'
GROUP BY rs.cx_business_unit_id, i.a_id;

最佳答案

也许是这样?

SELECT i.resp_id as id
, Count(1)
FROM int_result i, response_set rs, cx_store_child cbu
WHERE i.response_set_id = rs.id
AND rs.cx_business_unit_id = cbu.child_bu_id
AND cbu.business_unit_id = 30850
AND rs.survey_id IN (5550512,5550516,5550521,5550520,5590351,5590384,5679615,5679646,5691634,5699259,5699266,5699270)
AND i.q_id IN (52603091,52251250,52250724,52251333,52919541,52920117,54409178,54409806,54625102,54738933,54739117,54739221)
AND rs.t >= '2017-08-30 00:00:00'
AND rs.t <= '2017-09-30 00:00:00'
ORDER BY rs.cx_business_unit_id, i.a_id;

关于mysql - 如何使用子选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46523723/

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