Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Sql Developer Output formatting

select col1,col2,col3 from tab1 union all
select col1,col2,col3 from tab2

o/p-

COL1       COL2       COL3
6518    10060152650 534010002   
6518    10060152651 534010002   
6518    10060152652 534020003   
6526    10060153296 534004002   
6526    10060153310 534004542   
6526    10060153365 533011103   
6526    10060153328 534010002   
6526    10060153348 534010002   

I want it like this

COL1  COL2         COL3
6518  10060152650  534010002    
      10060152651  534010002    
      10060152652  534020003    
6526  10060153296  534004002    
      10060153310  534004542    
      10060153365  533011103    
      10060153328  534010002    
      10060153348  534010002

can any one help me out..!!

like image 485
imtiyaz283 Avatar asked Dec 11 '25 09:12

imtiyaz283


1 Answers

The SQL developer shows you the rows you select. As your rows contain a value in Col1 it will be shown. So your only solution is not to select it, or in your example: not to select it when the line before contains the same value already. Don't forget to sort.

select 
  case when col1 = lag(col1) over (order by col1, col2, col3) then
    null 
  else 
    col1
  end as colx
, col2
, col3
from
(
  select col1,col2,col3 from tab1 union all
  select col1,col2,col3 from tab2
)
order by col1, col2, col3
like image 54
Thorsten Kettner Avatar answered Dec 13 '25 21:12

Thorsten Kettner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!