Formatting bug

jmeyerjmeyer Posts: 70 Bronze 2
edited January 22, 2015 11:52AM in SQL Prompt
ORDER BY statements after a HAVING clause do not receive their aliases.

Repo:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Project_Express_MR53_stg] ([DataFile] [VARCHAR](50) NULL
                                             , [BF-SSN] [VARCHAR](50) NULL
                                             , [LN-SEQ] [VARCHAR](50) NULL
                                             , [LN-FAT-SEQ] [VARCHAR](50) NULL
                                             , [LC-FAT-REV-REA] [VARCHAR](50) NULL
                                             , [WX-FAT-REV-REA] [VARCHAR](50) NULL
                                             , [LD-FAT-APL] [VARCHAR](50) NULL
                                             , [LD-FAT-PST] [VARCHAR](50) NULL
                                             , [LD-FAT-EFF] [VARCHAR](50) NULL
                                             , [LD-FAT-DPS] [VARCHAR](50) NULL
                                             , [LC-CSH-ADV] [VARCHAR](50) NULL
                                             , [WX-CSH-ADV] [VARCHAR](50) NULL
                                             , [LD-STA-LON90] [VARCHAR](50) NULL
                                             , [LC-STA-LON90] [VARCHAR](50) NULL
                                             , [WX-STA-LON90] [VARCHAR](50) NULL
                                             , [LA-FAT-PCL-FEE] [VARCHAR](50) NULL
                                             , [LA-FAT-NSI] [VARCHAR](50) NULL
                                             , [LA-FAT-LTE-FEE] [VARCHAR](50) NULL
                                             , [LA-FAT-ILG-PRI] [VARCHAR](50) NULL
                                             , [LA-FAT-CUR-PRI] [VARCHAR](50) NULL
                                             , [PC-FAT-TYP] [VARCHAR](50) NULL
                                             , [WX-FAT-TYP] [VARCHAR](50) NULL
                                             , [PC-FAT-SUB-TYP] [VARCHAR](50) NULL
                                             , [WX-FAT-SUB-TYP] [VARCHAR](50) NULL
                                             , [LA-FAT-NSI-ACR] [VARCHAR](50) NULL
                                             , [WD-RPT-MTH-BEG] [VARCHAR](50) NULL
                                             , [WD-RPT-MTH-END] [VARCHAR](50) NULL
                                             , [WX-FIN-ATY-RPT-LN] [VARCHAR](50) NULL
                                             , [WX-LI-FAT-RAP] [VARCHAR](50) NULL
                                             , [IF-OWN] [VARCHAR](50) NULL
                                             , [IF-BND-ISS] [VARCHAR](50) NULL
                                             , [IC-LON-PGM] [VARCHAR](50) NULL
                                             , [LC-LO-AUT-RAL] [VARCHAR](50) NULL)
ON
  [PRIMARY]

GO


SELECT  s.[BF-SSN]
      , s.[LN-SEQ]
      , s.[LN-FAT-SEQ]
      , s.[WX-FIN-ATY-RPT-LN]
      , s.[LC-LO-AUT-RAL]
      , s.[LC-FAT-REV-REA]
      , s.[WD-RPT-MTH-END]
FROM    dbo.Project_Express_MR53_stg s
GROUP BY s.[BF-SSN]
      , s.[LN-SEQ]
      , s.[LN-FAT-SEQ]
      , s.[WX-FIN-ATY-RPT-LN]
      , s.[LC-LO-AUT-RAL]
      , s.[LC-FAT-REV-REA]
      , s.[WD-RPT-MTH-END]
HAVING  COUNT(*) > 1
ORDER BY [BF-SSN]
      , [LN-SEQ]
      , [LN-FAT-SEQ]
      , [WX-FIN-ATY-RPT-LN]
      , [LC-LO-AUT-RAL]
      , [LC-FAT-REV-REA]
      , [WD-RPT-MTH-END] 

Comments

Sign In or Register to comment.