oracle - Removing "duplicate" groups in SQL -
i'm trying rid of duplicate groups in sql, problem they're not really duplicates.
i have table this:
a | b 0 | 1 2 | 3
however, table adds b, end final table:
a | b 0 | 1 2 | 3 -------- 1 | 0 3 | 2
what i'm trying homecoming distinct pairs (the first table), , i'm having issues it. hints much appreciated!
try this:
select distinct (case when < b else b end) first, (case when < b b else end) sec t
if using oracle (which assumption sqlplus), can simplify to:
select distinct least(a, b), greatest(a, b) t
sql oracle
No comments:
Post a Comment