我必须将一些 SQL 从 PostgreSQL 迁移到 SQL Server (2005+)。在 PostgreSQL 上我有:
select count(id) as count, date
from table
group by date
order by count
limit 10 offset 25
现在我需要相同的 SQL,但用于 SQL Server。我像下面那样做了,但得到错误:Invalid column name 'count'.
如何解决?
select * from (
select row_number() over (order by count) as row, count(id) as count, date
from table
group by date
) a where a.row >= 25 and a.row < 35