MySQL Forums
Forum List  »  Newbie

Re: Display sum of table in one line of text?
Posted by: Claude Martin
Date: March 29, 2005 06:20AM

CREATE TABLE `matthew` (
`member` varchar(255) collate latin1_general_ci NOT NULL default '',
`kills` int(10) unsigned NOT NULL default '0',
`deaths` int(10) unsigned NOT NULL default '0'
) ENGINE=InnoDB

this will not work:
SELECT member, kills, deaths, (kills / deaths) AS score
FROM `matthew`
ORDER BY score

maybe this is better:

SELECT member, kills, deaths,
IF (deaths, kills / deaths, 'flawless') AS score
FROM `matthew`
ORDER BY score

There is also a function to round:
SELECT member, kills, deaths,
IF (deaths, ROUND( kills / deaths, 1 ) , 'flawless') AS score
FROM `matthew`
ORDER BY score

is this what you where looking for?

http://animalliberation.tk http://veganismus.ch
http://maqi.de http://tierrechtskochbuch.de

Options: ReplyQuote


Subject
Written By
Posted
Re: Display sum of table in one line of text?
March 29, 2005 06:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.