MySQL Forums
Forum List  »  Newbie

How to sum two aliased values in a query
Posted by: Ig Ta
Date: March 25, 2005 02:22PM

First of all sorry for my english but I hope someone can help me
in my problem.

I need to sum two aliased values in a query in order to order
the results.

The query looks like this:

SELECT t1.ID, t2.name1, t2.name2
COUNT(DISTINCT t3.pos > '10') AS res_1,
SUM(IF(t4.points = 'val' AND
t3.pos = $t4.val)) AS res_2,

till this point it's all ok, but when I try to sum the
two aliased values res_1 and res_2 I always get '0'
as result...

(IFNULL('res_1', 0) + IFNULL('res_2',0)) AS total

FROM
t1, t2, t3, t4

I tried it also with variables but I always got the
same result

Options: ReplyQuote


Subject
Written By
Posted
How to sum two aliased values in a query
March 25, 2005 02:22PM


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.