Please advise on how to get the GROUP BY coded in an acceptable way:
DECLARE @LO INT
DECLARE @HI INT
DECLARE @StartDate varchar(10)
DECLARE @EndDate varchar(10)
SELECT @StartDate = '01/01/2005'
SELECT @EndDate = '06/30/2005'
SELECT @LO = 250
SELECT @HI = 333
SELECT
StateCD
, CountyCD
, Zip
, Z.CityName
, Z.StateCode
, Z.CountyName
, 'Criteria' = 'JumboRange:' + Convert(varchar (4),@LO) + '-' +
Convert(varchar (4),@HI)
, 'StartingDate' = @StartDate
, 'ThruDate' = @EndDate
, JumboAmount = SUM(JumboAmount )
, JumboMortgages = SUM(JumboMortga ges)
, JumboFIXMortgag es = SUM(JumboFIXMor tgages)
, JumboFIXAmount = SUM(JumboFIXAmo unt)
, JumboARMMortgag es = SUM(JumboARMMor tgages)
, JumboARMAmount = SUM(JumboARMAmo unt)
FROM LoanDetails T INNER JOIN dbo.ZipCodesPre ferred Z
ON T.StateCD = Z.FIPS_State AND T.CountyCD = Z.FIPS_County AND T.Zip =
Z.ZipCode
GROUP BY
StateCD
, CountyCD
, Zip
, Z.CityName
, Z.StateCode
, Z.CountyName
, 'Criteria' = 'JumboRange:' + Convert(varchar (4),@LO) + '-' +
Convert(varchar (4),@HI)
, 'StartingDate' = @StartDate
, 'ThruDate' = @EndDate
DECLARE @LO INT
DECLARE @HI INT
DECLARE @StartDate varchar(10)
DECLARE @EndDate varchar(10)
SELECT @StartDate = '01/01/2005'
SELECT @EndDate = '06/30/2005'
SELECT @LO = 250
SELECT @HI = 333
SELECT
StateCD
, CountyCD
, Zip
, Z.CityName
, Z.StateCode
, Z.CountyName
, 'Criteria' = 'JumboRange:' + Convert(varchar (4),@LO) + '-' +
Convert(varchar (4),@HI)
, 'StartingDate' = @StartDate
, 'ThruDate' = @EndDate
, JumboAmount = SUM(JumboAmount )
, JumboMortgages = SUM(JumboMortga ges)
, JumboFIXMortgag es = SUM(JumboFIXMor tgages)
, JumboFIXAmount = SUM(JumboFIXAmo unt)
, JumboARMMortgag es = SUM(JumboARMMor tgages)
, JumboARMAmount = SUM(JumboARMAmo unt)
FROM LoanDetails T INNER JOIN dbo.ZipCodesPre ferred Z
ON T.StateCD = Z.FIPS_State AND T.CountyCD = Z.FIPS_County AND T.Zip =
Z.ZipCode
GROUP BY
StateCD
, CountyCD
, Zip
, Z.CityName
, Z.StateCode
, Z.CountyName
, 'Criteria' = 'JumboRange:' + Convert(varchar (4),@LO) + '-' +
Convert(varchar (4),@HI)
, 'StartingDate' = @StartDate
, 'ThruDate' = @EndDate
Comment