Quote:
|
Originally Posted by fstop
In a similar vein, I would also like to remove duplicate rows while displaying all columns in the query. Clnumber is the column I want to key on for duplicates.
|
Below is vendor specific(DB2) SQL using OLAP functions. I think Oracle should support the same syntax (except temp table).
with temp(ipname, clnumber, class, date) as
(values
('smith', 11111, 320, '2004-12-21'),
('smith', 11111, 420, '2004-12-22'),
('barnes', 22222, 320, '2004-12-21'),
('jones', 33333, 320, '2004-12-21'),
('jones', 33333, 320, '2004-12-21')
)
select ipname, clnumber, class, date from
( select
ipname, clnumber, class, date,
rownumber() over (partition by clnumber) as r
from temp) t
where r = 1
IPNAME CLNUMBER CLASS DATE
------ ----------- ----------- ----------
smith 11111 320 2004-12-21
barnes 22222 320 2004-12-21
jones 33333 320 2004-12-21
3 record(s) selected.