RE: DBI Count Distict

2003-06-27 Thread FARRINGTON, RYAN
Title: RE: DBI Count Distict





I would use the SQL server to make the counts for me... or you could take the query then make a hash using the first three digits as the key and make the value increment... then you just hash through the hash (hehehe) and get your final count... 

-Original Message-
From: steve silvers [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 27, 2003 8:52 AM
To: [EMAIL PROTECTED]
Subject: DBI Count Distict



Quick question I'm calling out a column called data which looks like so:


001A
001B
002A
002D
003D
003E
004A
005


I need to get the count of all 001 and 002 and 003... so on where 001 = 2 
and 002 = and 004 = 1...


I have


$sql = SELECT Data FROM table;


while (($Data) = $sth-fetchrow_array) {


 print $Data \n;
}


Any help greatly appreciated.
Thanks in advance
Steve


_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs





RE: DBI Count Distict

2003-06-27 Thread Tobias Hoellrich
Try: 

  select left(Data,3) as start, count(*) as occurances from table group by
start;

Hope this helps
   Tobias

PS: Tried this on mysql ...

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of steve silvers
 Sent: Friday, June 27, 2003 7:52 AM
 To: [EMAIL PROTECTED]
 Subject: DBI Count Distict
 
 
 Quick question I'm calling out a column called data which
 looks like so:
 
 001A
 001B
 002A
 002D
 003D
 003E
 004A
 005
 
 I need to get the count of all 001 and 002 and 003... so on
 where 001 = 2 
 and 002 = and 004 = 1...
 
 I have
 
 $sql  = SELECT Data FROM table;
 
 while (($Data) = $sth-fetchrow_array) {
 
   print $Data \n;
 }
 
 Any help greatly appreciated.
 Thanks in advance
 Steve

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs