gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-10-23 : 09:42:06
|
[code]DECLARE @t TABLE(Modem_ID char(5), [Date] date, [Time] int, Sent_Total int, Received_Total int);INSERT INTO @T(MODEM_ID, [DATE], [TIME], SENT_TOTAL, RECEIVED_TOTAL) VALUES ('COM10','2014-10-22', 1100, 1, 1), ('COM10','2014-10-22', 1200, 4, 4), ('COM16','2014-10-22', 1100, 1, 1), ('COM16','2014-10-22', 1200, 6, 5)SELECT [DATE], [TIME] , MAX(CASE WHEN MODEM_ID = 'COM10' THEN SENT_TOTAL END) AS COM10_SENT_TOTAL , MAX(CASE WHEN MODEM_ID = 'COM10' THEN RECEIVED_TOTAL END) AS COM10_RECEIVED_TOTAL , MAX(CASE WHEN MODEM_ID = 'COM16' THEN SENT_TOTAL END) AS COM16_SENT_TOTAL , MAX(CASE WHEN MODEM_ID = 'COM16' THEN RECEIVED_TOTAL END) AS COM16_RECEIVED_TOTALFROM @TGROUP BY [DATE], [TIME]ORDER BY [DATE], [TIME][/code] |
|
|