declare @t table (col int) insert into @t select 1 union all select 3 union all select 5 union all select 7 union all select 9select max(col) from (select top 3 * from @t) as t /* 5 */ 用的top的时候,里面最好写上order by
还真是order by的问题,问什么要加上order by才行呢? SELECT MAX(zskid) FROM (select top 131000 * from taoluTable order by zskid) AS temp这样就可以 不加上order by不也是从一个集合里面读取最大值吗?
declare @t table (col int)
insert into @t
select 1 union all
select 3 union all
select 5 union all
select 7 union all
select 9select max(col) from (select top 3 * from @t) as t
/*
5
*/
用的top的时候,里面最好写上order by
SELECT MAX(zskid) FROM (select top 131000 * from taoluTable order by zskid) AS temp这样就可以
不加上order by不也是从一个集合里面读取最大值吗?