0

How to get more columns along with distinct column values in Oracle ?

select DISTINCT cname 
from customer 
where code is not null;

I need cname, cvalue, cdate with distinct cname

Bsquare ℬℬ
  • 4,423
  • 11
  • 24
  • 44
Ravindra
  • 3
  • 2
  • 2
    Please edit your question to provide some sample input data and the expected output from that data. Does `select distinct cname, cvalue, cdate from customer where code is not null;` not do the trick? – Boneist Nov 08 '18 at 10:11
  • im getting : Ravi 78, Ravi 75 , i dont want duplicate expected output: cname cvalue cdate ================ Ravi 78 12-02-18 balu 89 09-07-18 – Ravindra Nov 08 '18 at 10:25
  • 1
    possible duplicate question [ORACLE Select Distinct return many columns and where](https://stackoverflow.com/questions/21778686/oracle-select-distinct-return-many-columns-and-where) – Mizuki Nov 08 '18 at 10:33

1 Answers1

0

Your question does not really make sense. DISTINCT does not affect columns, it eliminates duplicate rows. So if you have:

a    b    c
a    b    c
d    b    c

Using DISTINCT gives you:

a    b    c
d    b    c

You're going to have to be more specific in the output you're getting and what you want.

eaolson
  • 14,717
  • 7
  • 43
  • 58