SELECT DateTime, [$Second] AS Second, [I1D1] AS I1D1, [I2D1] AS I2D1, [I1D2] AS I1D2, [I2D2] AS I2D2
FROM
(SELECT DateTime, tagname, value FROM history where tagname='$Second' OR tagname='I1D1'OR tagname='I2D1'OR tagname='I1D2'OR tagname='I2D2') AS req
PIVOT
(COUNT (value)FOR tagname IN( [$Second], [I1D1], [I2D1], [I1D2], [I2D2] )) AS pvt
ORDER BY pvt.DateTime
2010-09-07 14:12:37.110 1 1 1 1 1
2010-09-07 14:12:38.000 1 0 0 0 0
2010-09-07 14:12:40.000 1 0 0 0 0
2010-09-07 14:12:42.000 1 0 0 0 0
2010-09-07 14:12:44.000 1 0 0 0 0
2010-09-07 14:12:46.000 1 0 0 0 0
2010-09-07 14:12:48.000 1 0 0 0 0
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 14