| Author |
print only the duplicate values in sql.
|
bhavin ragha
Greenhorn
Joined: Mar 28, 2012
Posts: 17
|
|
is there a method that will allow me to print only the duplicate values
here in a column
--------
1
1
2
3
3
the out put would be
---------
1
3
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
Native sql, you could execute this in a Java method ...
select colname from tablename
order by colname
group by colname having count(*) > 1;
Try it ...
Then understand what the "group by" and "having" do
Pat.
|
 |
bhavin ragha
Greenhorn
Joined: Mar 28, 2012
Posts: 17
|
|
i put this in and it did not work for me. it says "near "group": syntax error"
select releases.cd_id from releases
order by releases.cd_id
group by releases.cd_id
having count(*) > 1
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2384
|
|
|
Move the order by clause to the end of the statement. Order by must always go last.
|
 |
 |
|
|
subject: print only the duplicate values in sql.
|
|
|