Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql problem/question
Peter Shankey <shankeyp_at_charlestoncounty.org> wrote in message
news:388AF81A.CE86F1BF_at_charlestoncounty.org...
> A table has distinct values in column 1 (c1) how can I count the number
> of rows each distinct value has. I am looking for something like
>
> c1 number of rows
> --- ---
> v1 25
> v2 100
> v3 20
> v4 500
>
>
SELECT c1, count(*) AS numb FROM <table> GROUP BY c1
If you want a special sorting, add a SORT BY clause. If you want to constrain the result dependant of the number of rows, add HAVING numb >= x to the GROUP BY clause.
--
Thomas Received on Sun Jan 23 2000 - 08:20:03 CST