这听起来可能有点无聊,但我正在尝试计算查询中返回的总行数。我试过 COUNT() 无济于事。到目前为止,我有这个查询:
SELECT DISTINCT
a.*
, LEVEL AS n
, count(wipdatavalue) as total
FROM
(
SELECT
WIPDATAVALUE
, CONTAINERNAME
, una
, dulo
, (dulo - una) + 1 AS m
FROM
(
SELECT
WIPDATAVALUE
, CONTAINERNAME
, CASE
WHEN INSTR(wipdatavalue, '-') = 0 THEN
wipdatavalue
ELSE
SUBSTR(wipdatavalue, 1, INSTR(wipdatavalue, '-')-1)
END AS una
, CASE
WHEN INSTR(wipdatavalue, '-') = 0 THEN
wipdatavalue
ELSE
SUBSTR(wipdatavalue, INSTR(wipdatavalue, '-') + 1)
END AS dulo
FROM trprinting
WHERE containername = '8PB842613'
)
)A CONNECT BY LEVEL <= m
GROUP BY
WIPDATAVALUE
, CONTAINERNAME
, una
, dulo
, m
, LEVEL
ORDER BY N;
我也在尝试将 N 字段设置为 1 到 8,因为这应该是正确的输出。提前致谢。我知道你们会有所帮助:)