Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

How to get distinct sets of rows using SQL (Oracle)?

WITH hashes AS
(SELECT group,
        SUM(Ora_hash(Concat(Concat(account,field), value))) AS hash
 FROM table
 GROUP BY group)
SELECT account,
       field,
       value,
       group
FROM table
WHERE group IN (SELECT group
                FROM (SELECT group,
                             row_number() over (PARTITION BY hash ORDER BY NULL) AS rn
                      FROM hashes)
                WHERE  rn = 1);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #distinct #sets #rows #SQL
ADD COMMENT
Topic
Name
4+1 =