How can I use a value computed in my SQL query for further computations?

2006-04-17 Thread Daevid Vincent
Here is a paired down version of a query I want to make. How can I get the grandtotal column? I know about the HAVING clause, but that's only going to be good for weeding out rows I don't want. I just want to do some basic math here. SELECT a.*, DATE_FORMAT(a.created_on,'%m/%d/%y

RE: How can I use a value computed in my SQL query for further computations?

2006-04-17 Thread Daevid Vincent
To add to this, I will also want to be able to ORDER BY those three new columns (totalviews, totalclicks, grandtotal) as well.. I'm using mySQL 5 and innodb tables. I saw this page: http://dev.mysql.com/doc/refman/5.0/en/user-variables.html But it says: Note: In a SELECT statement, each

RE: How can I use a value computed in my SQL query for further computations?

2006-04-17 Thread Jay Blanchard
[snip] Here is a paired down version of a query I want to make. How can I get the grandtotal column? I know about the HAVING clause, but that's only going to be good for weeding out rows I don't want. I just want to do some basic math here. SELECT a.*, DATE_FORMAT(a.created_on,'%m/%d/%y

RE: How can I use a value computed in my SQL query for further computations?

2006-04-17 Thread Jay Blanchard
[snip] Here is a paired down version of a query I want to make. How can I get the grandtotal column? I know about the HAVING clause, but that's only going to be good for weeding out rows I don't want. I just want to do some basic math here. [/snip] More

RE: How can I use a value computed in my SQL query for further computations? [solved]

2006-04-17 Thread Daevid Vincent
Okay, well it turns out that this works exactly how I want/expect it to. The documentation was a bit confusing. SELECT a.*, DATE_FORMAT(a.created_on,'%m/%d/%y %h:%i:%s %p') AS created_on_format, DATE_FORMAT(a.timestamp,'%m/%d/%y %h:%i:%s %p') AS timestamp_format,