2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

A5:SQL Mk-2でSQL整形

Posted at

A5:SQL Mk-2でSQL整形

整形前
整形前.png

整形実行
整形実行.png

 ※もしくは「Ctrl+Q」

整形後
整形後.png

整形対象SQL

select distinct  tb1.id  ,tb1.name  ,tb1.type  ,case 
tb1.type   when '1' then 'typeA'   when '2' then
 'typeB'   else 'type0'   end as tp_namefrom  TB_ONE
 tb1   inner join (     select      tb2.id     
 ,tb2.point      ,tb2.category    from      TB_TWO
 tb2    where      tb2.category > 'X'  ) tb2_x    
on tb1.id = tb2.idwhere  tb2.point >= 100  and (tb1.type
 = 1 or tb1.type = 2) union select  * from  
(select * from TB_OLD)
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?