[thelist] Silly SQL

Joshua Olson joshua at waetech.com
Fri May 28 07:17:34 CDT 2004


> -----Original Message-----
> From: Ken Kogler
> Sent: Thursday, May 27, 2004 10:03 AM
>
> Greetings, all. I've got a query that looks like this:
>
>   select vUserVotedFor as user,
>          sum(vCitizenship) as ciTotal,
>          sum(vLeadership) as leTotal,
>          sum(vAcademics) as acTotal,
>          sum(vCharacter) as chTotal
>   from tblVotes
>   group by vUserVotedFor

> What I'm looking for is a way to also return the total of all four
> numeric columns added together (ciTotal + leTotal + acTotal + chTotal =
> ???).

Assuming that gives you the intermediate results you want, then the
following should give the results you ultimately want:

  select vUserVotedFor as user,
         sum(vCitizenship) as ciTotal,
         sum(vLeadership) as leTotal,
         sum(vAcademics) as acTotal,
         sum(vCharacter) as chTotal,
         sum(vCitizenship) +
         sum(vLeadership) +
         sum(vAcademics) +
         sum(vCharacter) as grandTotal
  from tblVotes
  group by vUserVotedFor

Does this help?

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list