---
title: "oracle 分组后取每组第一条数据"
author: "feicklpp"
date: "2019-06-20T16:29:53Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2019-06-20T16:29:53Z"
id: 2442010
url: "https://feicklpp.iteye.com/blog/2442010"
---

SELECT *

  FROM (SELECT ROW\_NUMBER() OVER(PARTITION BY test.x ORDER BY test.y DESC) rn, test.*

          FROM test)

 WHERE rn = 1;