Reputation: 73
Is doesn't seem to like the first comma after SUM(c.[chargeable weight])
. Do you guys can identify why? I genuinely can't understand the reason why it is doing this.
Select
(SUM(c.[Chargeable Weight]), MAX (ts.systemstamp), mm.MovementRef
FROM dbo.whsConsignment wc
INNER JOIN dbo.cgtConsignment c ON c.[Consignment Reference] = wc.ConsignmentReference
INNER JOIN dbo.tsAdditionalColInfo ts on ts.[ConsignmentReference]= wc.ConsignmentReference
inner join dbo.movConLink m on m.ConsignmentReference = c.[Consignment Reference]
inner join dbo.movMovement mm on mm.MovementID = m.MovementID
--AND wc.whsHeaderID = wh.WhsHeaderID
AND wc.StatusCode = 'NL'
AND c.[Service Type] = 'C'
--AND ts.SlackNoSlack like 'No Slack - Must Load%'
--and ts.SLackNoSLack like 'No Slack - Tripped%'
and ts.scheduledescription = 'No Slack - Tripped'
group by mm.MovementRef) as chargeableweight
--and ts.systemstamp = max (ts.systemstamp)
Into #2chargns
Upvotes: 0
Views: 638
Reputation: 2165
You missed the SELECT
within the brackets
SELECT * FROM
(SELECT SUM(c.[Chargeable Weight]) AS Sum, MAX (ts.systemstamp) AS Max, mm.MovementRef
FROM dbo.whsConsignment wc
INNER JOIN dbo.cgtConsignment c ON c.[Consignment Reference] = wc.ConsignmentReference
INNER JOIN dbo.tsAdditionalColInfo ts on ts.[ConsignmentReference]= wc.ConsignmentReference
inner join dbo.movConLink m on m.ConsignmentReference = c.[Consignment Reference]
inner join dbo.movMovement mm on mm.MovementID = m.MovementID
--AND wc.whsHeaderID = wh.WhsHeaderID
AND wc.StatusCode = 'NL'
AND c.[Service Type] = 'C'
--AND ts.SlackNoSlack like 'No Slack - Must Load%'
--and ts.SLackNoSLack like 'No Slack - Tripped%'
and ts.scheduledescription = 'No Slack - Tripped'
group by mm.MovementRef) as chargeableweight
--and ts.systemstamp = max (ts.systemstamp)
Into #2chargns
Upvotes: 1