您需要按类别进行分组。
SELECT CASE substr(item_no, 5, 1) WHEN 'C' THEN 'clothes' WHEN 'T' THEN 'toys' ELSE 'misc' END inv, count(item_no) total FROM box1 WHERE date <= sysdate GROUP BY CASE substr(item_no, 5, 1) WHEN 'C' THEN 'clothes' WHEN 'T' THEN 'toys' ELSE 'misc' END;
鉴于你的表达的本质,你只需要聚合 substr() :
substr()
select (case substr(item_no, 5, 1) when 'C' then 'clothes' when 'T' then 'toys' else 'misc' end) inv, count(item_no) total from box1 where date <= sysdate group by substr(item_no, 5, 1);