当前位置: 代码迷 >> Sql Server >> 这句SQL语句哪里有错啊该怎么解决
  详细解决方案

这句SQL语句哪里有错啊该怎么解决

热度:129   发布时间:2016-04-27 19:20:40.0
这句SQL语句哪里有错啊?
UPDATE TmpTbl SET ma5=(SELECT AVERAGE(first) FROM (SELECT TOP 5 FROM TmpTbl WHERE ID<5 ORDER BY ID DESC)) WHERE ID=5

------解决方案--------------------
SQL code
UPDATE   TmpTbl       SET   ma5=        (        SELECT   AVERAGE(first)   /*AVERAGE换为AVG*/            FROM   (                SELECT   TOP   5  /*这里缺少列*/                     FROM   TmpTbl                       WHERE   ID <5                       ORDER   BY   ID   DESC                )        )    WHERE   ID=5
------解决方案--------------------
UPDATE TmpTbl
SET ma5=(SELECT AVERAGE(first)
FROM (SELECT TOP 5 first FROM TmpTbl WHERE ID <5 ORDER BY ID DESC))
WHERE ID=5
------解决方案--------------------
UPDATE TmpTbl
SET ma5=(
SELECT AvG(first)
 FROM (
SELECT TOP 5 first 
FROM TmpTbl
WHERE ID <5
ORDER BY ID DESC)
)
WHERE ID=5
  相关解决方案