日期:2014-05-18  浏览次数:20462 次

这句SQL语错在哪
SELECT   MAX(id)   FROM   (SELECT   TOP   25   id   FROM   xx_table   ORDER   BY   addtime   DESC)

------解决方案--------------------
SELECT MAX(id) FROM (SELECT TOP 25 id FROM xx_table ORDER BY addtime DESC) a
加个别名

------解决方案--------------------
视图内不能 order by
------解决方案--------------------
另外还要加别名.
------解决方案--------------------
SELECT MAX(id) FROM (SELECT TOP 25 id FROM xx_table ORDER BY addtime DESC) as t

------解决方案--------------------
SELECT MAX(id) FROM (SELECT TOP 25 id FROM xx_table ORDER BY addtime DESC)t

------解决方案--------------------
SELECT MAX(id) FROM xx_table
WHERE id in(SELECT TOP 25 id FROM xx_table ORDER BY addtime DESC)


------解决方案--------------------
up
------解决方案--------------------
with table as
(
select id Rank() over(order by addtime Desc) rank from XX_table
)
select max(id) from tagle where rank <25
------解决方案--------------------
SELECT MAX(id) FROM (SELECT TOP 25 id FROM xx_table ORDER BY addtime DESC) as z
这个错误我犯过!!!


------解决方案--------------------



+ AS TableName