首页 > 解决方案 > 使用 DENSE_RANK() MySQL 缺少右括号

问题描述

我不确定我的语法在哪里出错。我需要根据以下条件显示顶级供应商invoice_total

select *
from (
        select vendor_id, invoice_total,
        dense_rank () over(partition by vendor_id order by invoice_total asc)
          as ranking
        from invoices) a1

标签: mysqlsqlmysql-workbench

解决方案


where a1.ranking = 1为 SQL 的外部添加:

select *
from (
        select vendor_id, invoice_total,
        dense_rank () over(partition by vendor_id order by invoice_total asc)
          as ranking
        from invoices) a1
where a1.ranking = 1;

推荐阅读