Skip to content
Tako Lee edited this page Apr 10, 2014 · 9 revisions
  • WHEN/THEN keyword in the same line, inner block indent from 0 to n

    Option: fmt080_case_indent = n, type: int.

    Option: fmt081_case_then_in_newline = false, type: TFmtBoolean.

    SELECT productnumber, 
           name, 
           'Price Range' = CASE  
                               WHEN listprice = 0 THEN 'Mfg item - not for resale'  
                               WHEN listprice < 50 THEN 'Under $50'  
                               WHEN listprice >= 50  
                                    AND listprice < 250 THEN 'Under $250'  
                               WHEN listprice >= 250  
                                    AND listprice < 1000 THEN 'Under $1000'  
                               ELSE 'Over $1000'  
                           END  
    FROM   production.product  
    ORDER  BY productnumber; 
  • THEN keyword in new line, inner block indent from 0 to n

    Option: fmt080_case_indent = n, type: int.

    Option: fmt081_case_then_in_newline = true, type: TFmtBoolean.

    SELECT productnumber, 
           name, 
           'Price Range' = CASE  
                             WHEN listprice = 0  
                             THEN 'Mfg item - not for resale'  
                             WHEN listprice < 50  
                             THEN 'Under $50'  
                             WHEN listprice >= 50  
                                  AND listprice < 250  
                             THEN 'Under $250'  
                             WHEN listprice >= 250  
                                  AND listprice < 1000  
                             THEN 'Under $1000'  
                             ELSE 'Over $1000'  
                           END  
    FROM   production.product  
    ORDER  BY productnumber;  
  • First WHEN keyword in newline

    Option: fmt173_case_first_when_in_newline = false, type: TFmtBoolean.

    SELECT productnumber, 
           name, 
           'Price Range' = CASE  WHEN listprice = 0 THEN 'Mfg item - not for resale'  
                                 WHEN listprice < 50 THEN 'Under $50'  
                                 WHEN listprice >= 50  
                                      AND listprice < 250 THEN 'Under $250'  
                                 WHEN listprice >= 250  
                                      AND listprice < 1000 THEN 'Under $1000'  
                                 ELSE 'Over $1000'  
                           END  
    FROM   production.product  
    ORDER  BY productnumber; 

Clone this wiki locally