Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4631
  • Last Modified:

How to do SELECT UNIQUE on multiple fields

Hello,

I have a table with the following columns:

A.KEY
A.VAL1
A.VAL2

A.KEY is unique. A.VAL1 and A.VAL2 may have any values.

Is it possible to do a SELECT UNIQUE using multiple fields from table A?

If table A has these values:

KEY    VAL1    VAL2
  1        A         B
  2        C         D
  3        A         B
  4        C         D
  5        A         B
  6        E         F

I would like the select to return rows made up of unique values in both VAL1 and VAL2. It should produce the following:

A  B
C  D
E  F

I've been using this code to deal with it:

  SELECT UNIQUE(STUFF)
  FROM (SELECT (VAL1 || '^' || VAL2) STUFF FROM A)

Is there a better way to do this? What is "The Oracle Way"?

Points will be awarded to the most elegant, correct solution.

Thanks for the help.

Jim
0
jrollins138
Asked:
jrollins138
1 Solution
 
hans_vdCommented:
select distinct val1, val2 from a
0
 
pennnnCommented:
SELECT DISTINCT val1, val2 FROM A;
Hope that helps!
0
 
jrollins138Author Commented:
I knew there had to be something easy.

Thanks folks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now