Could you please help me correct my formatting? I cannot figure out what I'm doing wrong. Thanks!
The multi-part identifier "tbl.dteEffectiveDate" could not be bound.
The multi-part identifier "tbl.nbrFuelSurcharge" could not be bound.
Invalid Column name 'dteEffectiveDate'.
Invalid column name 'nbrFuelSurcharge'.
SELECT
'Year'=Year(vtr."Billing Date"),
'Month'=Month(vtr."Billing Date"),
'Miles'=SUM(vtr."TotalMiles"),
'Weight'=SUM(vtr.Weight),
'Total Cost'=SUM(vtr.TotalARAmt),
'Base Cost'=SUM(vtr."A/R Invoice Amount"),
'FSC'=AVG(tbl.nbrFuelSurcharge),
'Count'=COUNT(vtr."Evans Order Number")
FROM Mother.dbo.viewTransReporting AS vtr
inner join
(SELECT
'Monthy'=Month(tbl.dteEffectiveDate), 'FSCY'=AVG(tbl.nbrFuelSurcharge)
FROM
Mother.dbo.tblFuelSurcharge
GROUP by tbl.dteEffectiveDate) AS tbl
ON
Month(vtr."Billing Date")=Month(tbl.dteEffectiveDate)
WHERE vtr."CustomerShortName"=N'HELLERMANN'
AND (vtr."Billing Date">= CONVERT(DATETIME, '2009-01-01 00:00:00', 102))
AND (vtr."Billing Date"< DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 0))
AND vtr."Routed"=1 AND (vtr.Mode='LTL' OR vtr.Mode='VOLUME')
AND (tbl.dteEffectiveDate>= CONVERT(DATETIME, '2009-01-01 00:00:00', 102))
AND (tbl.dteEffectiveDate< DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 0))
GROUP by Month(vtr."Billing Date")
The multi-part identifier "tbl.dteEffectiveDate" could not be bound.
The multi-part identifier "tbl.nbrFuelSurcharge" could not be bound.
Invalid Column name 'dteEffectiveDate'.
Invalid column name 'nbrFuelSurcharge'.
SELECT
'Year'=Year(vtr."Billing Date"),
'Month'=Month(vtr."Billing Date"),
'Miles'=SUM(vtr."TotalMiles"),
'Weight'=SUM(vtr.Weight),
'Total Cost'=SUM(vtr.TotalARAmt),
'Base Cost'=SUM(vtr."A/R Invoice Amount"),
'FSC'=AVG(tbl.nbrFuelSurcharge),
'Count'=COUNT(vtr."Evans Order Number")
FROM Mother.dbo.viewTransReporting AS vtr
inner join
(SELECT
'Monthy'=Month(tbl.dteEffectiveDate), 'FSCY'=AVG(tbl.nbrFuelSurcharge)
FROM
Mother.dbo.tblFuelSurcharge
GROUP by tbl.dteEffectiveDate) AS tbl
ON
Month(vtr."Billing Date")=Month(tbl.dteEffectiveDate)
WHERE vtr."CustomerShortName"=N'HELLERMANN'
AND (vtr."Billing Date">= CONVERT(DATETIME, '2009-01-01 00:00:00', 102))
AND (vtr."Billing Date"< DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 0))
AND vtr."Routed"=1 AND (vtr.Mode='LTL' OR vtr.Mode='VOLUME')
AND (tbl.dteEffectiveDate>= CONVERT(DATETIME, '2009-01-01 00:00:00', 102))
AND (tbl.dteEffectiveDate< DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 0))
GROUP by Month(vtr."Billing Date")