这是我的查询;
select token, average, ntile(100) over (order by average) as percentile
from responses;
如何使用token
字段从中返回特定行?理想情况下,在一个查询中,而不是两个。
答案 0 :(得分:1)
使用子查询:
select r.*
from (select token, average, ntile(100) over (order by average) as percentile
from responses
) r
where token = <whatever>;
如果您只是在查询中添加where
子句,它将在窗口函数之前应用并影响结果。