我有三个选择查询,它们根据不同的 where 子句从同一个表中返回总记录、成功记录和失败记录。我想将所有这些语句的结果合并到一个表中以制作我的存储过程,但结果表应具有三个不同的 cdr 、成功、失败列
SELECT Count(*) AS cdr
FROM ABC AS c WITH (NOLOCK)
WHERE APPID IN( 1, 2 )
AND CALLDATE = '2012-10-09'
SELECT Count(*) AS success
FROM ABC AS d WITH (NOLOCK)
WHERE APPID IN( 44, 45 )
AND CALLDATE = '2012-10-09'
AND HANGUPCODE IN ( 'man', 'mach' )
SELECT Count(*) AS fail
FROM ABC WITH (NOLOCK)
WHERE APPID IN( 44, 45 )
AND CALLDATE = '2012-10-09'
AND HANGUPCODE NOT IN ( 'man', 'mach' )
联合在一列中给出结果,因此它不起作用。任何其他想法