List:General Discussion« Previous MessageNext Message »
From:Kathy Mazur Worden Date:June 30 2006 2:57pm
Subject:summing values
View as plain text  
I'd like to sum up values from two different columns in one table that
is constructed like this:

 

CREATE TABLE `nominations`

 ( `id` smallint(5) unsigned NOT NULL auto_increment, 

`name` varchar(255) default NULL, 

`SectionA_Nominee1` varchar(255) NOT NULL default 'n/a', 

`SectionA_Nominee2` varchar(255) NOT NULL default 'n/a', 

`SectionB_Nominee1` varchar(255) NOT NULL default 'n/a',

 `SectionB_nominee2` varchar(255) NOT NULL default 'n/a'

`submittedwhen` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP, `submittedfrom` varchar(50) NOT NULL default
'unavailable', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1

 

The table has a row added each time a vote is cast.  For each section
one or two votes can be placed from a list of 4 nominees.

 

Since one person can be listed in both 1 and 2 in each section (just not
in the same row) I need to sum up that person's votes between the two
columns.  I've tried summing two subqueries but it errors out because of
returning two values.  

 

Any other ways to accomplish this?

 

Kathy Mazur Worden

Prairie Area Library System

 


Thread
summing valuesKathy Mazur Worden30 Jun
  • Re: summing valuesPeter Brawley30 Jun
    • RE: summing valuesKathy Mazur Worden30 Jun
  • quickie for a non-blonde!Helen M Hudson13 Jul
    • Re: quickie for a non-blonde!Mike Aubury13 Jul