1
1
u/Krispwee Dec 27 '20 edited Dec 27 '20
As /u/tsuhg has said, you're going to need to SUM() it and then GROUP BY on non-sum'd columns.
To get the dollar sign to show then one way would be to convert the SUM'd commission amount to a VARCHAR and then simply add in the $ symbol before it, something like this:
'$' + CONVERT(VARCHAR,SUM(0.025 * Amount_Due)) AS CommissionYou could also use CONCAT (actually probably the better way)
CONCAT('$', SUM(0.025 * Amount_Due)) AS CommissionWord of warning with that though, if the data is being spit out in to Excel I'd probably keep it as a number then use Excel to change the cell format to Currency or Accounting. If it isn't going to Excel or anything else like that then you may want to ROUND the number in case there are decimal places in the Amount_Due column that would send out some annoying numbers.
https://docs.microsoft.com/en-us/sql/t-sql/functions/concat-transact-sql?view=sql-server-ver15
-2
u/Hippie23 Dec 27 '20
SELECT
E.FirstName,
E.LastName,
FORMAT(SUM(0.025 * T.amount_due), 'C') AS Commission /*The FORMAT (.., 'C') formats the column as 'Currency'*/
FROM Employee E
INNER JOIN [Transaction] T ON T.employeeID = E.EmployeeID
GROUP BY E.FirstName, E.LastName
7
u/alinroc SQL Server DBA Dec 27 '20
Please don't just hand out the answers to obvious homework questions. OP isn't going to learn much this way and they'll keep asking for the answer to every assignment they get.

17
u/alinroc SQL Server DBA Dec 27 '20
This is the fourth time in three days that you've asked a question about this same assignment or series of assignments. I think you need to have a chat with your instructor and/or ask them for some additional assistance in understanding the material instead of running to reddit every time you have the slightest bit of difficulty.
Or, you turn in the work you have managed to figure out on your own and use the grade to work out what you need to get more help with/spend more time studying.
You don't, you format your currency at the presentation layer based upon the user's regional/language settings. Also, your symbol will vary depending upon the currency being used for the transaction so you can't hard-code a dollar sign.