select top 4 * from tb where id not in(select top 4 * from tb order by id) order by id
上面有错误,这个可以 select top 4 * from (select top 8 from 记录集 order by 排序字段 desc) order by 排序字段 asc
SELECT TOP 4 * FROM (SELECT TOP 8 FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)) ORDER BY commend DESC 报错阿
SELECT TOP 4 * FROM (SELECT TOP 8 FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY commend desc ) a ORDER BY commend asc
SELECT TOP 4 * FROM news_table WHERE (newsid NOT IN (SELECT TOP 4 newsid FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY newsid DESC)) AND (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY newsid DESC 这个好像行
要求 from 后的查询结果给个别名,起成什么都行 SELECT TOP 4 * FROM (SELECT TOP 8 FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)ORDER BY commend desc ) a ORDER BY commend asc
SELECT TOP 4 a.* FROM ( SELECT TOP 8 * FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY commend desc ) a ORDER BY commend asc
不好意思8后少个星号 SELECT TOP 4 * FROM (SELECT TOP 8 * FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)ORDER BY commend desc ) a ORDER BY commend asc
SELECT TOP 4 a.* FROM ( SELECT TOP 8 * FROM news_table WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY commend desc ) a ORDER BY a.commend asc
order by id
select top 4 *
from (select top 8 from 记录集 order by 排序字段 desc)
order by 排序字段 asc
FROM (SELECT TOP 8
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118))
ORDER BY commend DESC
报错阿
FROM (SELECT TOP 8
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118) ORDER BY commend desc ) a
ORDER BY commend asc
FROM news_table
WHERE (newsid NOT IN
(SELECT TOP 4 newsid
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)
ORDER BY newsid DESC)) AND (picchk = 0) AND (shenghe = 1) AND (typeid = 118)
ORDER BY newsid DESC
这个好像行
SELECT TOP 4 *
FROM (SELECT TOP 8
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)ORDER BY commend desc )
a
ORDER BY commend asc
FROM ( SELECT TOP 8 *
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)
ORDER BY commend desc
) a
ORDER BY commend asc
SELECT TOP 4 *
FROM (SELECT TOP 8 *
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)ORDER BY commend desc )
a
ORDER BY commend asc
FROM ( SELECT TOP 8 *
FROM news_table
WHERE (picchk = 0) AND (shenghe = 1) AND (typeid = 118)
ORDER BY commend desc
) a
ORDER BY a.commend asc