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
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 ...
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