Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql problem/question

Re: sql problem/question

From: Thomas Muller <ttm_at_nextel.no>
Date: Sun, 23 Jan 2000 15:20:03 +0100
Message-ID: <x4Ei4.11032$in5.184114@news1.online.no>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US