Devide columns

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
lammspillning
Forum Newbie
Posts: 14
Joined: Fri Aug 17, 2007 10:50 am

Devide columns

Post by lammspillning »

Ok I think this is rather basic..
How would I do if I want to devide a value in a column with a value in another column in a table?
I want to devide the value in my column "vote_sum" with the value in "vote_tot",so that I get an average value and echo it. I'm not sure how to do this..//thanx
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Devide columns

Post by pickle »

This isn't a coding question - it's a databases question. I've moved the topic to the appropriate forum.

Something like this should work:
[sql]SELECT  vote_sum/vote_totalFROM  some_table[/sql]
assuming vote_sum and vote_total aren't aggregate values.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply