[Solved] how to group by


WITH sample_data AS
  (SELECT 1 AS id, 10 AS age, 11 AS name, 'A' AS type FROM dual
  UNION ALL
  SELECT 2, 0, 1, 'B' FROM dual
  UNION ALL
  SELECT 3, 9, 11, 'C' FROM dual
  UNION ALL
  SELECT 4, 10, 11, 'D' FROM dual
  UNION ALL
  SELECT 5, 10, 11, 'E' FROM dual
  UNION ALL
  SELECT 6, 10, 11, 'F' FROM dual
  )
SELECT listagg(type,',') within GROUP (
ORDER BY type) types,
  SUM(age)
FROM sample_data
GROUP BY DECODE(type,'A',1,'B',1,'C',2,'D',2,3)

result

types    sum(age)
A,B        10
C,D        19
E,F        20

solved how to group by