• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Queries and SQL > 43. Place a Grand Total in a Query

Place a Grand Total in a Query

Use a Union query to combine raw data records with the data total.

Here’s a neat way to list the records in a table and have the total appear at the bottom. First, create a Select query to return the table records; then use the Union statement to combine them with the data total. The Sum aggregate function handles returning the total. The assumption, of course, is that the data is numeric.

You need to enter this type of query in the SQL pane because the query grid doesn’t support creating or displaying Union queries. Here is a sample SQL statement that combines sales records with the sum of the sales:

	SELECT tblSales.Amount
	FROM tblSales
	UNION ALL SELECT Sum(tblSales.Amount) AS SumOfAmount
	FROM tblSales;

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint