[thelist] Silly SQL

Ken Kogler gsls at kenkogler.com
Thu May 27 09:02:54 CDT 2004


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

And that returns this:

  User        ciTotal leTotal acTotal chTotal
  ----------- ------- ------- ------- -------
  Ablood        55      55      40      50
  Bruckman      63      65      59      62
  Tkrimminger   59      65      55      59
  Jhines        66      66      68      68
  Jmward        61      65      66      63
  Ccrouch       60      63      65      63

What I'm looking for is a way to also return the total of all four
numeric columns added together (ciTotal + leTotal + acTotal + chTotal =
???). I want to return the total score for each user. I tried nesting
another query in there, but I can't quite get my brain around how this
is supposed to work. 

I know I can just work with the recordset through ASP/PHP/whatever, but
I won't learn anything that way. I want to see if I can get it to work
through SQL. This is SQL Server 2000 running on Win2k if that helps.

Any thoughts?

--ken



More information about the thelist mailing list