求大神帮忙 SQL筛选 最高 最低值
数据表GatherData中 的列 P1,SensorID,GatherNO,T,H
Select P1,SensorID,GatherNO,?T,H from (select * from (SELECT dbo.Sensor.*, dbo.GatherData.ID GatherDataID,dbo.GatherData.SensorID, dbo.GatherData.GatherNo, dbo.GatherData.WarnHandleID, dbo.GatherData.WarnType, dbo.GatherData.T, dbo.GatherData.TW, dbo.GatherData.H, dbo.GatherData.HW FROM dbo.GatherData LEFT OUTER JOIN dbo.Sensor ON dbo.GatherData.SensorID = dbo.Sensor.ID ) bbb where GatherNo>='2013-03-22 09:10:55' and GatherNo<='2013-05-22 09:10:55') a
分数不多 求大神帮忙修改下:要求能得出一个表 表中只有四行数据 分别是
max(T)
min(T)
max(H)
min(H)
------解决方案--------------------早说吗,你又说“只要”四列
SELECT P1 ,
SensorID ,
GatherNO ,
T ,
H ,
MAX(T) ,
MIN(T) ,
MAX(H) ,
MIN(H)
FROM ( SELECT *
FROM ( SELECT dbo.Sensor.* ,
dbo.GatherData.ID GatherDataID ,
dbo.GatherData.SensorID ,
dbo.GatherData.GatherNo ,
dbo.GatherData.WarnHandleID ,
dbo.GatherData.WarnType ,
dbo.GatherData.T ,
dbo.GatherData.TW ,
&nbs