How can I write an SQL query that lists a set of detail rows with a total at the bottom?
You can use a UNION operation to append the total as a row at the end of the list of items, as illustrated in the following example: SELECT ‘ITEM’ AS ROWTYPE, PARTID, PRICE FROM PART UNION SELECT ‘TOTAL’ AS ROWTYPE, 0 AS PARTID, SUM( PRICE ) AS PRICE FROM PART ORDER BY ROWTYPE, PARTID To make sure that the total row is at the end of the result set, you must include the Order By clause.