因此,查询A将查询B的结果(4个数字的列表)并对其进行查询。我怎么能用这个语法?当我只有1个值用作输入时,SQL似乎只是喜欢。有什么建议吗?
select servers.hostname,
SUM(enm_amos_commands.successcount) AS successCommandCount,
SUM(enm_amos_commands.failurecount) AS failedCommandCount,
ROUND(AVG(enm_amos_commands.successcount+enm_amos_commands.failureCount),0) AS avg_per_minute,
MAX(enm_amos_commands.successcount+enm_amos_commands.failureCount) AS max_per_minute
from enm_amos_commands, servers
where servers.id IN
(
SELECT
servers.id
FROM
servers
WHERE
servers.hostname LIKE '%111-scp%' or servers.hostname LIKE '%111-amos%'
and servers.siteid = 6)
答案 0 :(得分:0)
只需使用join
即可。我猜你打算:
select s.hostname,
SUM(eac.successcount) AS successCommandCount,
SUM(eac.failurecount) AS failedCommandCount,
ROUND(AVG(eac.successcount + eac.failureCount), 0) AS avg_per_minute,
MAX(eac.successcount + eac.failureCount) AS max_per_minute
from enm_amos_commands eac join
servers s
on eac.server_id = s.id
where (s.hostname like '%111-scp%' or s.hostname LIKE '%111-amos%') and
s.siteid = 6
group by s.hostname;