Reputation: 63
I have the following query:
SELECT YEAR(SalesDate) AS Year, COUNT(VehicleID) AS VehicleCount
FROM CarsSales GROUP BY Year(SalesDate)
UNION ALL
SELECT 'Total', SUM(SalesDate) FROM CarCount;
Which returns the following result set. I need the + signs to say "Total" but I am confused as to why it isn't printing out like I expected it to.
Year VehicleCount
2000 1228
2001 4768
2002 14004
++++++++++++++ 20000
Upvotes: 2
Views: 1963
Reputation: 30088
I don't have a DB2 database handy, but I'm guessing that your problem is that you are trying to mix integer data ( YEAR(SalesDate) ) with character data (the literal 'Total'), and that the + signs are DB2's way of displaying 'NaN'.
Try changing YEAR(SalesDate) to CHAR(YEAR(SalesDate)) so that all entries in the first column will be CHAR types.
Upvotes: 2