oracle 选取出现次数最多的前5条数据

时间:2014-05-08 17:30:41   收藏:0   阅读:484
SELECT
	*
FROM
	(
		SELECT
			PROJECT_LISTING.MATERIAL,
			COUNT (*) AS "出现次数"
		FROM
			PROJECT_LISTING
		WHERE
			PROJECT_LISTING.MATERIAL IS NOT NULL
		GROUP BY
			PROJECT_LISTING.MATERIAL
		ORDER BY
			COUNT (*) DESC
	) WHERE ROWNUM <= 5

	ORDER BY
			COUNT (*) DESC 是关键排序

COUNT (*) AS "出现次数"  这个可以不写,只是为了看的明白

oracle 选取出现次数最多的前5条数据,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!