Reputation: 1117
I have a table like below,
cid uid aid gid NAME evn
1 1 1 1 aa aa
1 1 1 2 bb aa
1 1 2 2 bb bb
1 2 1 1 aa aa
2 1 1 1 aa aa
2 1 1 1 aa aa
2 2 2 2 bb bb
2 2 2 2 aa bb
3 3 2 2 aa bb
3 3 2 2 aa bb
but I want query output should be look like
cid uid aid gid NAME evn
1 1 1 1 aa aa
1 2 1 1 aa aa
2 1 1 1 aa aa
2 2 2 2 bb bb
3 3 2 2 aa bb
In my input table,I have cid,uid combination like (1,1),(1,1)(1,1) repeating, but in my output query result should be (1,1).i.e, one time. I am not bothering about other columns.I have tried groupBy but it is not working as expected.
Upvotes: 0
Views: 34
Reputation: 113
You can use DISTINCT
keyword like this :-
SELECT DISTINCT cid, uid, aid, gid, name, evn FROM ....
Upvotes: 1
Reputation: 1271231
If you don't care about other columns, then just use aggregation:
select cid, uid, min(aid), min(gid), min(name), min(evn)
from t
group by cid, uid;
This pulls "arbitrary" values from the other columns.
Upvotes: 0