clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36234 in the last week).

create table your_table (some_date, code, description, amount) as select date '2022-01-01', 1001, 'Produt A', 1234 from dual union all select date '2022-02-01', 1001, 'Produt A', 2345 from dual union all select date '2022-03-01', 1001, 'Produt A', 3456 from dual
3 rows affected
 hidden batch(es)


select some_date, case when count(distinct code) > 1 then 'Various' else to_char(max(code)) end as code, case when count(distinct description) > 1 then 'Various' else max(description) end as description, sum(amount) as amount from your_table group by some_date order by some_date;
SOME_DATE CODE DESCRIPTION AMOUNT
01-JAN-22 1001 Produt A 1234
01-FEB-22 1001 Produt A 2345
01-MAR-22 1001 Produt A 3456
 hidden batch(es)


insert into your_table (some_date, code, description, amount) select date '2022-01-01', 1002, 'Produt B', 4321 from dual union all select date '2022-02-01', 1003, 'Produt B', 5432 from dual union all select date '2022-03-01', 1004, 'Produt B', 6543 from dual
3 rows affected
 hidden batch(es)


select some_date, case when count(distinct code) > 1 then 'Various' else to_char(max(code)) end as code, case when count(distinct description) > 1 then 'Various' else max(description) end as description, sum(amount) as amount from your_table group by some_date order by some_date;
SOME_DATE CODE DESCRIPTION AMOUNT
01-JAN-22 Various Various 5555
01-FEB-22 Various Various 7777
01-MAR-22 Various Various 9999
 hidden batch(es)