Apply style on Partition by clause - aligning order by

This statement is formatting as follows (with the order by in column 1)
SELECT<br>&nbsp; &nbsp; &nbsp;cols<br>&nbsp;&nbsp;&nbsp;&nbsp;,Row_Cnt =&nbsp;ROW_NUMBER()&nbsp;OVER&nbsp;(PARTITION&nbsp;BY&nbsp;A.part<br>ORDER&nbsp;BY&nbsp;A.PDate DESC<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>FROM<br>&nbsp; &nbsp; &nbsp;table&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;A
How do I get it to align with the partition
SELECT<br>&nbsp; &nbsp; &nbsp;cols<br>&nbsp;&nbsp;&nbsp;&nbsp;,Row_Cnt =&nbsp;ROW_NUMBER()&nbsp;OVER&nbsp;(PARTITION&nbsp;BY&nbsp;A.part<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORDER&nbsp;BY&nbsp;A.PDate DESC<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>FROM<br>&nbsp; &nbsp; &nbsp;table&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;A
Tagged:

Answers

  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi @MattB_SCA!

    I can get that formatting with the following:
    - Data>Clauses> set "Clause alignment" to " to statement"
    - Parentheses>Short parentheses contents> disable 'Collapse parentheses if contents are shorter than x characters"

    Can you please give this a try?

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Thanks for the response Jessica.

    I can now get it to:
    &nbsp;&nbsp;&nbsp;&nbsp;,Row_Cnt =&nbsp;ROW_NUMBER()&nbsp;OVER&nbsp;(PARTITION&nbsp;BY&nbsp;A.part ORDER&nbsp;BY&nbsp;A.PDate DESC)
    which is better than the ORDER in the left column, but ideally I'd like the ORDER aligned under the PARTITION
    &nbsp;&nbsp;&nbsp;&nbsp;,Row_Cnt =&nbsp;ROW_NUMBER()&nbsp;OVER&nbsp;(PARTITION&nbsp;BY&nbsp;A.part 
                                      ORDER&nbsp;BY&nbsp;A.PDate DESC)
    Matt
  • Jessica RJessica R Posts: 1,319 Rose Gold 4

    No worries, Matt!

    I think that disabling Data (DML)>Subqueries>"Collapse subqueries shorter than x characters" will do the trick for you- can you please give this a try?

    If not, I've attached an example style that should format it as you're looking for:

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Sign In or Register to comment.