Solved

SQL having count greater than 1

Posted on 2003-11-11
2
19,429 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pivot not using aggregate yield error 3 54
ODBC Question 3 41
Session that filled up my transaction logs 1 55
T-SQL Default value in Select? 5 26
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Read about achieving the basic levels of HRIS security in the workplace.
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…

776 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