List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 18 1999 8:37am
Subject:Re: How to connect to a FoxPro DB
View as plain text  
On Tue, 1999-08-10 09:20:42 -0500, Jason Radford wrote:
> I have a query in which I would like to use sum() to return the number
> of rows returned.  Such as:
> 
> select to_domain,number=count(*)
> from sendmail
> where to_doman like '%fred%'
> group by to_domain
> 
> what I'd like to do is sum the variable 'number' to get the number of
> rows returned.  Problem is that to_domain is a char datatype and sum()
> only works on numberic datatypes.

Hmm, let's see if I understand your problem:

  SELECT to_domain, COUNT(*) AS number
  FROM   sendmail
  WHERE  to_domain LIKE '%fred%'
  GROUP BY to_domain;

Doesn't that do what you want?

For counting the number of rows (per group) use COUNT(),
for summing up numerical values use SUM().
I just don't see the problem ...
 
Regards,
  Martin

PS: Plaese, don't hit 'reply' to start a new thread, just for replying!
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
How to connect to a FoxPro DBJuergen Hoffmann18 Aug
  • Re: How to connect to a FoxPro DBJason Radford18 Aug
    • Re: How to connect to a FoxPro DBMartin Ramsch18 Aug
  • Re: How to connect to a FoxPro DBMartin Ramsch18 Aug
  • Re: How to connect to a FoxPro DBTonu Samuel18 Aug
    • Re: How to connect to a FoxPro DBJuergen Hoffmann18 Aug
  • Re: How to connect to a FoxPro DBVan18 Aug
  • Re: How to connect to a FoxPro DBVan18 Aug