Reputation:
Can't figure out how to use SQL Server’s functions to format the average price in Query to money/currency (2 decimal places with a dollar sign)
Currently I have this:
SELECT AVG(devMarketCap) AS 'Average Market Cap',
MIN(devMarketCap) AS 'Lowest Market Cap',
MAX(devMarketCap) AS 'Highest Market Cap'
FROM developer INNER JOIN GAME
ON developer.devID = GAME.devID
WHERE devCountry = 'USA' AND gameGenre = 'Fantasy';
Upvotes: 0
Views: 1217
Reputation: 13248
Try:
SELECT format(AVG(devMarketCap), 'C', 'en-us') AS 'Average Market Cap',
format(MIN(devMarketCap), 'C', 'en-us') AS 'Lowest Market Cap',
format(MAX(devMarketCap), 'C', 'en-us') AS 'Highest Market Cap'
FROM developer INNER JOIN GAME
ON developer.devID = GAME.devID
WHERE devCountry = 'USA' AND gameGenre = 'Fantasy';
Other formatting options: http://msdn.microsoft.com/en-us/library/hh213505.aspx
Upvotes: 1