如果间隔不是"满",即无法通过简单的日期或时间间隔来满足条件,可以通过以下方法使OVER()中的结果为空:
SELECT column1, column2,
CASE WHEN interval <> '满' THEN NULL ELSE OVER(...) END AS result
FROM table_name;
SELECT column1, column2,
ROW_NUMBER() OVER (PARTITION BY column1 ORDER BY column2) AS row_num,
...
FROM table_name
WHERE interval = '满' AND row_num > 0;
SELECT column1, column2,
OVER(...) AS result
FROM (
SELECT column1, column2
FROM table_name
WHERE interval = '满'
) subquery;
以上是三种常见的方法,根据具体情况选择适合的方法来使OVER()中的结果为空。
领取专属 10元无门槛券
手把手带您无忧上云