引导式测验 · 中等 等级

如何使用 AI 测验编写 SQL 窗口函数

检查 SQL 窗口分区、排名关系和运行总计框架以及购买示例、缺失日期和最新事件选择。

问题 1 的 8

对于 5、7 和 4 的订购购买,哪些逐行运行总计与指南的框架相符?

预览每个问题8 问题

当您参加测验时,就会出现答案和解释。

  1. 对于 5、7 和 4 的订购购买,哪些逐行运行总计与指南的框架相符?
    • 5, 7 and 4
    • 5, 12 and 16
    • 16, 16 and 16
    • 5, 14 and 12
  2. 对于降序分数 100、100 和 90,RANK 会产生哪个序列?
    • 1, 2 and 3
    • 1, 1 and 2
    • 2, 2 and 3
    • 1, 1 and 3
  3. 哪个函数给出并列分数 100、100 和 90 的排名 1、1 和 2?
    • DENSE_RANK
    • ROW_NUMBER
    • RANK
    • LAG
  4. 最新事件查询使用仅按两个事件共享的时间戳排序的 ROW_NUMBER。在它们之间做出可预测的选择需要什么?
    • Remove the account partition
    • Replace the final result with an unqualified DISTINCT
    • Add an appropriate tie-breaker to the window ordering
    • Assume insertion order resolves every tie
  5. 为什么日销售额的LAG不能代表昨天的销售额?
    • LAG always refers to the first row of the entire table
    • The previous recorded row may be separated by missing dates
    • LAG automatically groups all dates in one month
    • The function replaces missing dates with zero
  6. An ORDER BY appears inside OVER. What is still needed if the final displayed result must have a specified order?
    • Only a PARTITION BY with the same column
    • Only a ROWS frame using the same ordering column
    • No further clause because window ordering guarantees display order
    • A final ORDER BY for the query result
  7. Why should a tie-breaker not be added indiscriminately to RANK when equal scores should share a rank?
    • It can change which rows are peers and therefore change tied ranks
    • It leaves peer membership unchanged because only the first ordering column matters
    • It changes only the final display order and never the window calculation
    • It preserves equal-score ranks while automatically making their row numbers predictable
  8. In PostgreSQL, how can a query filter rows using a window value calculated in an inner SELECT?
    • Use that value in the same SELECT's WHERE without another query level
    • Replace OVER with GROUP BY in every case
    • Filter in an outer query or common table expression
    • Assume every database supports an identical QUALIFY clause