Это то, что я имел в виду, говоря, что - если тип данных DA.GID
равен VAR(CHAR)2
- вы должны сравнивать его со строками, а не числами. Обратите внимание на строки 4, 5 и 14.
SQL> select apex_string.format(t1.col_heading, null, null, 1, 2, null)
2 || rtrim(xmlagg(xmlelement
3 (e, apex_string.format(t2.col_heading, null, null, da.n_service,
4 case da.gid when '15' then '3' --> here
5 else '1' --> here
6 end,
7 coalesce(da.service_type, 'Grand Total')), '').extract('//text()')
8 order by da.c ).getclobval(), ','),
9 min(da.gid)
10 from data_aggs da
11 cross join std_template t1
12 cross join std_template t2
13 where da.balance_type is null
14 and da.gid in ( '11', '15') --> here
15 group by t1.col_heading
16 ;
[EDIT]
Применяя TO_NUMBER
к DA.GID
в CASE
, но оставляя его как в строке 14.
4 case to_number(da.gid) when 15 then 3 --> here
5 else 1 --> here
6 end,
14 and da.gid in ('11', '15') --> here