日期:2014-05-17 浏览次数:20531 次
select * from (Select Temperature, A.DateHappen,A.BoxSN from Monitor_Temperature A inner Join (Select BoxSN,Max(DateHappen) As DateHappen from Monitor_Temperature where 1=1 Group By BoxSN) B On A.BoxSN=B.BoxSN And A.DateHappen=B.DateHappen) as LastTempearature,Basic_Box where LastTempearature.BoxSN=Basic_Box.BoxSN and TemperatureState=1 and (Temperature<2 or Temperature>8)
--思路1 使用ROW_NUMBER select * from ( select Row_Number() over (order by id) as row, * from table ) as tmp where row between page_no1 and page_no2 --你需要分页的页码区间 --思路2 使用TOP select top 10 * from table where id > ( select max(id) from (select top 20 id from table order by id) as tmpTab ) order by id --取id在21到30之间的记录
------解决方案--------------------
表机构发一把,必须用join on ?