This is what is being used nowDECLARE @DateFrom datetimeDECLARE @DateTo datetimeSET @DateFrom = '1 October 2007'SET @DateTo = '31 October 2007'SELECT 'TDK' As Machine, ISNULL(SUM(Weight), 0) AS Sum_Weight, ISNULL(SUM(Length), 0) / 1000 AS Sum_Length, COUNT(Weight) AS CntFROM SteelRecordsWHERE (Processed_TDK_DateTime BETWEEN @DateFrom AND @DateTo)UNION ALLSELECT 'BDL' As Machine, ISNULL(SUM(Weight), 0) AS Sum_Weight, ISNULL(SUM(Length), 0) / 1000 AS Sum_Length, COUNT(Weight) AS CntFROM SteelRecordsWHERE (Processed_BDL_DateTime BETWEEN @DateFrom AND @DateTo)UNION ALLSELECT 'APS' As Machine, ISNULL(SUM(Weight), 0) AS Sum_Weight, ISNULL(SUM(Length), 0) / 1000 AS Sum_Length, COUNT(Weight) AS CntFROM SteelRecordsWHERE (Processed_APS_DateTime BETWEEN @DateFrom AND @DateTo)UNION ALLSELECT 'FDB' As Machine, ISNULL(SUM(Weight), 0) AS Sum_Weight, ISNULL(SUM(Length), 0) / 1000 AS Sum_Length, COUNT(Weight) AS CntFROM SteelRecordsWHERE (Processed_FDB_DateTime BETWEEN @DateFrom AND @DateTo)UNION ALLSELECT 'ABC' As Machine, ISNULL(SUM(Weight), 0) AS Sum_Weight, ISNULL(SUM(Length), 0) / 1000 AS Sum_Length, COUNT(Weight) AS CntFROM SteelRecordsWHERE (Processed_ABC_DateTime BETWEEN @DateFrom AND @DateTo)
Works fine, fast enough really, just runs a simple report page.But im curious as to if there is any better way of doing this?(Hopefully the code is sufficent enough to be understandable, if not I will do some example data)