If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > a possibly impossible SUM question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-04, 10:32
raven2200 raven2200 is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
a possibly impossible SUM question

Hello there,

I've looked all over the place and can't seem to find if it is even possible to do something. Let's say that you have a table with two columns (I'm dealing with floats, which is why I'm SUMming VARCHARs):

CREATE TABLE test (val0 VARCHAR(255), val1 VARCHAR(255));

Now lets say that for each row in this table, you want to display:
(val0 / SUM(val0)) + (val1 / SUM(val1))

How would one go about this? If run as written, you'll get back a one line answer, which is just the values for the first pair of (val0, val1). I would very much like this to be computed for ALL of the rows. I realize that it has to do with SUM being a function that groups things, but I'm fairly new to this whole db scene, and don't yet fully understand how to pull this off.

You're help would be greatly appreciated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On