oracle - SQL selection query that discards rows that share some value with another row -
suppose have next sql table, these sample values:
id    date        user     publish ---------------------------------- 1     05/20/16    peter    1 2     05/20/16    peter    2      <= discarded 3     05/20/16    john     2 4     05/28/16    john     1 5     05/28/16    john     2      <= discarded 6     07/01/16    peter    2 7     07/01/16    john     2   what want query select rows in case there 2 rows same date , user, retrieve 1 'publish' value '1', in example rows 1, 3, 4, 6 , 7.
i resolve problem programmatically wonder if exists way solve proper sql query.
any appreciated.
this discard first row (ordered publish) each group of date , user:
select id, "date", user, publish   (   select t.*,          row_number() on ( partition "date", user order publish ) rn     table_name t ) rn = 1;      
Comments
Post a Comment