easy SQL question

Damon Pillinger daisychain at iinet.net.au
Fri Oct 14 07:22:58 CDT 2005


Many thanks Ivan,

I knew it would be simple, the filed names are not those given they are
actually SALESPERSON, TOTALSALES, TOTALVAT, TOTALUNITS etc...

Thanks

Best Regards

Damon L. Pillinger
Jensen 2005 by Daisychain
www.daisychain.no-ip.biz
Phone : 03 9532 1220
Fax : 03 9532 1280


-----Original Message-----
From: valentina-bounces at lists.macserve.net
[mailto:valentina-bounces at lists.macserve.net] On Behalf Of Ivan Smahin
Sent: Thursday, 13 October 2005 7:05 PM
To: Valentina Developers
Subject: Re: easy SQL question

Hello Damon,

Thursday, October 13, 2005, 11:38:27 AM, you wrote:

DP> Hi Guys,
 
DP> Not good enough at SQL to figure this out myself.
 
DP> Table with two fields  name & Count
 
DP>             name    count
DP>             John     2
DP>             Ben      3
DP>             John     5
DP>             John     23
DP>             Ben      3
DP>             Ben      7
DP>             John     3
DP>             John     8
 
 
DP> What I want is this returned 
 
DP> John     41
DP> Ben      13
 
DP> I have read up on unique and distinct but cannot figure it out, the
SUM
DP> bit is easy but I think I have to have one call for each person
 
DP> select SUM(count) from data where name="John"
DP> select SUM(count) from data where name="Ben"
 
DP> and there could be hundreds of names , so this would be BAD.
 
select name, SUM(count) from data GROUP BY name

BTW,  It  would  be  better  to  have  another  field name rather then
"count". SQL-parser might be confused with it because it is keyword.


-- 
Best regards,
 Ivan                            mailto:IvanSmahin at public.kherson.ua

_______________________________________________
Valentina mailing list
Valentina at lists.macserve.net
http://lists.macserve.net/mailman/listinfo/valentina


More information about the Valentina mailing list