Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 19538
  • Last Modified:

SQL having count greater than 1

Hi all,
i need help with some sql.  I have a table with 200,000 rows of data.  one of the columns ref contains non unique values.  I'm only interested in these rows if the ref values are not unique.  If this is the case i'd like to know how many times they are being used.

i would expect my select statement to return just 2 values, namely ref and the number of times ref value was used in the table.

any suggestions?

regards Peewee
0
Peewee
Asked:
Peewee
1 Solution
 
lauszCommented:
Try this

select namely , count(*)
from yourtable
group by namely
having count(*)>1
0
 
PeeweeAuthor Commented:
aplogies done it with...

set rowcount 10000

select ref, count(ref) as cnt from order
where ref != null
and ref != ''
group by ref
having count(ref) > 1
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now