Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL++ - Programming with the C++ API to MySQL
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
ODBC - ODBC with the MySQL Connector/ODBC driver
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
summing values

summing values

2006-06-30       - By Peter Brawley

 Back
Reply:     1     2     3  

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

Unclear. Where is a user's 1 or 2 recorded? What is a "sum .. between
two columns"?

PB

-- --

Mazur Worden, Kathy wrote:
> 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
>
>  
>
>
>  
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006
>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
&gt;Since one person can be listed in both 1 and 2 in each section
(just not<br>
&gt;in the same row) I need to sum up that person's votes between the
two<br>
&gt;columns.&nbsp; I've tried summing two subqueries but it errors out
because of<br>
&gt;returning two values.&nbsp; <br>
<br>
Unclear. Where is a user's 1 or 2 recorded? What is a "sum .. between
two columns"?<br>
<br>
PB<br>
<br>
-- --<br>
<br>
Mazur Worden, Kathy wrote:
<blockquote
cite="mid384D1CF49B99B44AA1D51B1246FE51A198E6F5@(protected)"
type="cite">
 <pre wrap="">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




 </pre>
 <pre wrap="">
<hr size="4" width="90%">
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006
 </pre>
</blockquote>
</body>
</html>

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=mysql@(protected)