1.

Solve : MySQL - add integer to column resulted from SUM function?

Answer»

Hey guys,

I need help, I have never done something like this but I'm sure it should be possible.

Basically TAKE this query:

Code: [Select]SELECT SUM(column1) AS total
FROM table1
I would like to KNOW if there is a WAY to add say 5 for example to the total column from the WHERE clause.

Something like this:

Code: [Select]SELECT SUM(column1) AS total
FROM table1
WHERE total + 5
That's all. Reason why I want to achieve this is because I have 2 TABLES which return almost the same data so I need to add column results together. If there is an ALTERNATIVE I would like to hear that too.

Thank you in advance guys.I don't think I quite understand; WHERE is used to determine what fits a query; essentially it either matches, or it doesn't.

if you want to add 5 to the resultset, you can use SELECT SUM(column1) + 5, I believe.



Discussion

No Comment Found