Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL having count greater than 1

Posted on 2003-11-11
2
Medium Priority
?
19,513 Views
Last Modified: 2009-12-24
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
Comment
Question by:Peewee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
lausz earned 200 total points
ID: 9721787
Try this

select namely , count(*)
from yourtable
group by namely
having count(*)>1
0
 
LVL 5

Author Comment

by:Peewee
ID: 9721816
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question