Im trying to do a Top 10 but adding multiple columns together and grouping them by component between a certain date range, if i take the SUM's out it works like a charm, but when i put them back in i get the exception below, its been a while and i could just be having a brainfart.
sql = "SELECT TOP 10 ComponentName, (SUM(ISNULL(ulCompSizeFailure,0)) + SUM(ISNULL(ulLeadCountFailure,0)) + SUM(ISNULL(ulVPSHeightFailure,0))) as Total
FROM [i_import_slot_vision_errors]
WHERE DATE_TIME >= @startdata2
AND DATE_TIME < @enddata2
GROUP BY ComponentName
ORDER BY (SUM(ISNULL(ulCompSizeFailure,0)) + SUM(ISNULL(ulLeadCountFailure,0)) + SUM(ISNULL(ulVPSHeightFailure,0))) as Total DESC"
Problem is im getting an SQL exception, "Incorrect syntax near the keyword 'as'."
ORDER BY Total DESC.