I have a query that allows me to retrieve customer orders.
Select ID, OrderID, Item, Price from customerOrders
Where Order = 1
is there a way of totalling up the final amount to pay and have it visible below, but still be able to view all details needed in the sql query, for example
ID | OrderID | Item | Price
1 | 1 | Book | 9.99
2 | 1 | DVD | 12.99
total = 22.98
Many thanks in advance
Two steps:
1, To generate the SUM, you need to add it to the result set using UNION ALL. UNION adds a DISTINCT operation which isn’t required, even if in your case it won’t change the result.
2, To sort it in the order you want (sum at the bottom), you can use the NULL ID as an identifier.