我的查询语句是这样的,但是分页应该怎么写呢
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_NUMBERselect * from (select Row_Number() over (order by id) as row, * from table ) as tmpwhere row between page_no1 and page_no2 --你需要分页的页码区间--思路2 使用TOPselect top 10 * from table whereid > (select max(id) from (select top 20 id from table order by id) as tmpTab)order by id--取id在21到30之间的记录
[解决办法]
表机构发一把,必须用join on ?