Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Sql :: SQL Aliases with COUNT() 
Sql :: How to Alter column in SQL Server - NAYCode.com 
Sql :: SQL DATEADD(date_part, number, date) 
Sql :: flask sqlalchemy decimal 
Sql :: groupby sort sql hive 
Sql :: big table in mysql 
Sql :: postgres drop all tables owned by a user 
Sql :: how many rows can postgres handle 
Sql :: SQL Query Orderby Two or More Columns and by number of characters 
Sql :: configurasi database whmcs 
Sql :: How to write triggers to increment or decrement the number of employees 
Sql :: sql restore database from bak file 
Sql :: sql to move data from one table to another 
Sql :: t sql list week start date and end date for a year 
Sql :: ring get column value from the fetched row using the odbc_getdata() 
Sql :: mamp find mysql port number mac 
Sql :: sqlite headers 
Sql :: power query case when 
Sql :: union statement mysql 
Sql :: sum over partition by postgresql 
Sql :: sintax checker sql 
Sql :: fast sql column count 
Sql :: connecting mySQL to STS 
Sql :: sql 2year 
Sql :: sqlite 
Sql :: how to select multiple columns in sql 
Sql :: how to open database 
Sql :: ssms connect with connection string 
Sql :: sql query made by rahuldev 
Csharp :: minimize button c# 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =