Instead of using the following query to display the sum of a column at the bottom, is there another method than using the Union query
select amount
fr
The other option is to use SUM()
and GROUP BY()
See: http://dev.mysql.com/doc/refman/5.0/en/group-by-modifiers.html
SELECT year, SUM(profit) FROM sales GROUP BY year
This gives you yearly profit without a UNION. You can also add conditionals just like in COUNT()
WITH ROLLUP should perform exactly what you are doing.