如何将 oracles rownum 应用于 impala?

How can I apply oracles rownum to impala?

我想将 oracle 查询转换为 impala。

select name,class,floor
from class.students
where name = 'ted' 
and grad ='a'
and rownum<2

虽然impala无法识别rownum

我尝试在所选列中用group by解决它,但我认为它不正确。

此外,rownum 用作限制,或者它获取唯一的行以防我们有重复项?

您可以使用 limit 模仿 oracle rownum。您也可以使用 offset 来控制行数。 Impala limit 不会重复数据删除,您需要使用 distinct 来执行此操作。另请注意 Impala 首先获取数据然后应用 limit 与 oracle 不同。

select name,class,floor
from class.students
where name = 'ted' 
and grad ='a'
limit 2 -- This will show 2 records.