Reputation: 19375
I have a database table like the following:
date col
1 A
1 A
1 B
2 C
I would like to get the unique values of col
for each date
. So as output I am looking for:
date col
1 A
1 B
2 C
I tried the following without success:
SELECT DISTINCT DATE, COL
FROM MYDATA
GROUP BY DATE
But I am getting :
ORA-00979: not a GROUP BY expression
What is the issue here?
Thanks!
Upvotes: 0
Views: 699
Reputation: 222432
You are mixing DISTINCT
and GROUP BY
. Use either one or the other.
Both below queries will produce the expected result.
Option 1 :
SELECT DISTINCT DATE, COL FROM MYDATA
Option 2 :
SELECT DATE, COL FROM MYDATA GROUP BY DATE, COL
Upvotes: 3