17,377
社区成员
发帖
与我相关
我的任务
分享
SELECT a.china_name,COUNT(b.opr_state_id) AS cnt
FROM spc_room AS a
INNER JOIN rme_rack AS b ON a.room_id=b.posit_id AND b.opr_state_id='170001'
WHERE a.issupportidc=1
GROUP BY a.china_name
HAVING COUNT(b.opr_state_id)>1000
少了个分组条件
--题1
SELECT a.china_name,COUNT(b.opr_state_id) AS cnt
FROM spc_room AS a
INNER JOIN rme_rack AS b ON a.room_id=b.posit_id AND b.opr_state_id='170001'
WHERE a.issupportidc=1
HAVING COUNT(b.opr_state_id)>1000
--题2
--in
SELECT b.* FROM rme_eqp AS a
INNER JOIN rem_port AS b ON a.eqp_id=b.super_res_id
WHERE a.posid_id IN (
SELECT room_id FROM spc_room
WHERE issupportidc=1
)
--exists
SELECT b.* FROM rme_eqp AS a
INNER JOIN rem_port AS b ON a.eqp_id=b.super_res_id
WHERE exists (
SELECT room_id FROM spc_room AS c
WHERE issupportidc=1 AND a.posit_id = c.room_id
)