且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用重复的行进行多列分区?

更新时间:2023-02-02 21:57:41

在该表上存在导致重复的错误或者您需要使用DISTINCT。

Hi members,

I have a set of SQL Stored procedure to use partitioning for my ranking to get percentile. by doing the below partitioning I am able to get my percentiles data right. However my problem is there are duplicates in each row. E.g for each DESC there are multiple duplicates when it is suppose to be only 1 row. Why is this so?

row_nums AS 
	(
		SELECT DATE, DESC, NUM, ROW_NUMBER() OVER (PARTITION BY DATE, DESC ORDER BY NUM ASC) AS Row_Num
		FROM ******
	)
SELECT ................. 

There is a bug causing duplicates on that table or you need to use DISTINCT.