How to format the piece, thanks!

Shreklili 61 Reputation points
2021-08-20T02:41:42.683+00:00

case when Right(AA.BBMonth,2)="01" then AA.BBMonth when isnull(CC.DDDate,"") <> "" and (select top 1 EE from FF where CC.GG =GGID and CC.DDDate between HHStartDate and HHEndDate) = AA.EE then AA.BBMonth when Isnull(AA.IIMonth,"")<>"" then (case when (select COUNT(1) from AA where BBMonth =Addmonth(AA.BBMonth,-1) and JJ =AA.JJ) = 0 then AA.BBMonth else (select top 1 LLMonth from AA where JJ =AA.JJ and BBMonth =Addmonth(AA.BBMonth,-1)) end) else (case when (select COUNT(1) from AA where BBMonth =Addmonth(AA.BBMonth,-1) and JJ =AA.JJ) = 0 then AA.BBMonth else (select top 1 LLMonth from AA where JJ =AA.JJ and BBMonth =Addmonth(AA.BBMonth,-1)) end) End

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,601 questions
{count} votes

1 answer

Sort by: Most helpful
  1. EchoLiu-MSFT 14,581 Reputation points
    2021-08-20T02:51:37.643+00:00

    Hi @Shreklili ,

    Welcome to the microsoft TSQL Q&A forum!

    Please refer to a similar question I answered a few days ago:
    How to format T-SQL Statements in the SSMS

    If you have any question, please feel free to let me know.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments