Solved

SQL having count greater than 1

Posted on 2003-11-11
2
19,368 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
2 Comments
 
LVL 6

Accepted Solution

by:
lausz earned 50 total points
Comment Utility
Try this

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

Author Comment

by:Peewee
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now