Usually, sql implementations come with some formatting features. Here, I'd suggest a "break column". Specify like break on A on B mayhap with a skip n to highlight a value change in A or B .
Not sure if I understood the "o/p values are dynamic" part, but see if this helps:
SQL>
SQL> SELECT * FROM mytable;
A B STATUS
---------- ---------- ----------
Insert Update Old
Insert Update New
Insert Update Final
3 rows selected.
SQL>
SQL> -- Using CASE expression
SQL> SELECT CASE status WHEN 'Old' THEN a ELSE NULL END AS a,
2 CASE status WHEN 'Old' THEN b ELSE NULL END AS b,
3 status
4 FROM mytable
5 ;
A B STATUS
---------- ---------- ----------
Insert Update Old
New
Final
3 rows selected.
SQL>
SQL> -- Using DECODE function
SQL> SELECT DECODE(status, 'Old', a, NULL) AS a,
2 DECODE(status, 'Old', b, NULL) AS b,
3 status
4 FROM mytable
5 ;
A B STATUS
---------- ---------- ----------
Insert Update Old
New
Final
3 rows selected.
SQL>
SQL>