为什么提取行对此SQL有问题

时间:2019-04-03 14:22:43

标签: sql sql-server

尝试使用FETCH时,我不理解以下错误。我正在尝试使用提取来实现分页。

  

“行”附近的语法不正确。期望来自。

// Now it's redeclared, but without a parameter?
void A_Pain();
// ...
state_t states[NUMSTATES] = {
// ...
    {SPR_PLAY,6,4,{A_Pain},S_PLAY,0,0}, // S_PLAY_PAIN2
// ...
}

2 个答案:

答案 0 :(得分:2)

您需要的语法正在流行:

select empId 
from employees
where empId > 0
group by empId
having count(*) > 1
order by empId
offset 0 rows
fetch next 10 rows only;

您的查询将永远不会执行,因为empId在外部查询中不带有group by子句。

答案 1 :(得分:1)

在黑暗中刺伤,但猜想您实际上是在追击:

SELECT empId
FROM employees
GROUP BY empId
HAVING COUNT(*) > 1
ORDER BY empId OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;