On Fri, 2008-08-15 at 13:57 +0100, Pat Rice wrote:
> hi
> I would like know how to count multiple occurances in a sql query.
>
> eg.
>
> row would be:
> tom, tom , tom, john,pat,pat
>
> and this would produce
> tom 3
> john 1
> pat 2
>
>
> I've tried this but I am only gettting 1 back
> select count(*) from commitCurrent where company =(select distinct
> company from commitCurrent);
>
> Any ideas?
>
> I know its not exactly perl but, I have the script written in perl.
>
> Thanks in advance
> Pat
>
First, you would be better of asking this of an SQL group; try to find
one for the database you are using.
Second, all RDBM have an interactive program to access the database; use
it to test your SQL statements before you insert them into a Perl
program. It will save on debugging.
Third, try:
SELECT company, COUNT(*)
FROM commitCurrent
GROUP BY company;
--
Just my 0.00000002 million dollars worth,
Shawn
"Where there's duct tape, there's hope."
"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/