我使用以下查询:
SELECT Print_NUMBER,
COUNT(Print_NUMBER) TotalCount
FROM LS_Print_Queue
WHERE event_id = 11862
GROUP BY PRINT_NUMBER
HAVING COUNT(PRINT_NUMBER) > 1
ORDER BY COUNT(PRINT_NUMBER) DESC
并返回一个重复的打印数字表,以及该特定打印数量的重复数量。我想要做的是总结这些数据,并提供一定数量的重复数据。因此,如果我有26行,每行有2个重复,则它将返回52,或者如果其中一个重复行有三个重复,则它将返回53.如何在Oracle PL / SQL中完成此操作?
答案 0 :(得分:2)
您可以使用子查询轻松完成:
select sum(TotalCount)
from (SELECT Print_NUMBER, COUNT(Print_NUMBER) as TotalCount
FROM LS_Print_Queue
WHERE event_id = 11862
GROUP BY PRINT_NUMBER
HAVING COUNT(PRINT_NUMBER) > 1
) t
答案 1 :(得分:0)