Oracle 去重求和方式一

SELECT
	* 
FROM
	( SELECT ROW_NUMBER ( ) OVER ( PARTITION BY CASE_ID ORDER BY DETECT_TIME ) rn, JCZF_DANGER.* FROM JCZF_DANGER ) j
	LEFT JOIN (
	SELECT
		case_id,
		sum( NVL( PENALTY_ORG_FINE, 0 ) ) AS orgTotalMoney,
		SUM( NVL( PENALTY_PERSON_FINE, 0 ) ) AS PersonTotalMoney 
	FROM
		JCZF_DANGER 
	GROUP BY
		case_id 
	) m ON j.case_id = m.case_id 
WHERE
	rn = 1

你可能感兴趣的:(数据库)