469,326 Members | 1,411 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

how can i select one row out of duplicates in a table.

lets say i have a table C with following columns-
C1 C2 C3
1 2 3
1 4 9
2 3 1
1 4 7
3 9 6
1 1 1
2 2 2
3 3 3
now i want max value of c2 column corresponding to values c1 column.
means for c1= 1 max c2 = 4
but we have two values for c1=1 and c2=4. here i want any of the two values..

so the final out put would look something like this -

C1 C2 C3
1 4 7
2 3 1
3 9 6

first I used select c1,c2,c3 from C where (c1,c2)in (select c1, max(c2) from C group by c1);

but i was getting the out put...
c1 C2 C3
1 4 7
1 4 9
2 3 1
3 9 6

here i want just one row corresponding to C1=1.

please giud me how should i proceed.



regards
khushbu
Jul 19 '10 #1
0 1195

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Botao | last post: by
3 posts views Thread by Kall, Bruce A. | last post: by
9 posts views Thread by =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.