Weird formatting issue. Sub Select related  

  

0

I have the following SQL I pasted into the formatter:

select a, b, c

  from (select a, b, c

                  from (select a, b, c from table)

When it formats the columns in the first select align properly, but the sub select it pushes the second column and all others after it (b and c in this case) in by 1 character on the first sub select and 3 characters on the second sub sub select.  It also right aligns the from and any joins with those pushed in columns instead of the select.  I have auto indent selected.  I also have no insert initial indention characters.  My SQL Main options are number of spaces = 0

SELECT a,

                b,

                c,

   FROM (SELECT a,

                                    b,

                                    c,

                       FROM (SELECT a,

                                                           b,

                                                           c,

                                              FROM table)

 

Do I have some formatting option set incorrectly?

1 Answer
0

Hi Lynnl,

there is nothing you can do incorrectly. It is just because SQL Formatting has so many different use cases that it may take a while to find the best formatting settings. 

You can try several options

  • set linebreak after "(" for sub-selects
  • or increase the number of spaces to "8" and set "no spaces inside brackets"
  • or switch on "smart indent and set "no spaces inside brackets"

See one example in attached screenshot

Regards

Guido

I set a linebrake after "(" and that did it. I would still prefer to keep it on the same line, but I would rather have everything lined up. Thank you.

Your Answer


 
Preview 0 Revisions Saved
Share:

Please Login or Register