MySQL Question

JSEB

Newb
Apr 2, 2020
13
14
I am new to MySQL and I am trying to figure out this problem and I have used every resource I know of.

So basically the code is
SQL:
SELECT EMPLOYEE.EMP_NUM, EMP_LNAME, SUM(ASSIGN_HOURS) AS SumOfASSIGN_HOURS, SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARGE
FROM EMPLOYEE, ASSIGNMENT
WHERE EMPLOYEE.EMP_NUM = ASSIGNMENT.EMP_NUM
GROUP BY EMP_NUM
ORDER BY EMP_NUM;

And it looks like this:


I need the decimals in the numbers to be rounded upwards to match this:

I have tried using the round() tag but I am getting syntax errors when using that.
Post automatically merged:

I actually just found out a working way to do it:
SQL:
SELECT  ASSIGNMENT.EMP_NUM,
        EMPLOYEE.EMP_LNAME,
        FORMAT(Sum(ASSIGNMENT.ASSIGN_HOURS),1) AS SumOfASSIGN_HOURS,
        FORMAT(Sum(ASSIGNMENT.ASSIGN_CHARGE),2) AS SumOfASSIGN_CHARGE
FROM    EMPLOYEE, ASSIGNMENT
WHERE   EMPLOYEE.EMP_NUM = ASSIGNMENT.EMP_NUM
GROUP BY ASSIGNMENT.EMP_NUM, EMPLOYEE.EMP_LNAME
Post automatically merged:

Following up on this problem, I now have the correct table/information I now need to remove comma's from numbers? I have searched but I do not fully understand?

 
Last edited:

JSEB

Newb
Apr 2, 2020
13
14
ROUND should work, do you have the error you were seeing?

SQL:
REPLACE(FORMAT(Sum(ASSIGNMENT.ASSIGN_CHARGE),2), ',', '')
should also work, but I'd try to use the round approach.
Yes, I finally figured it out a day or so later. Thank you for this though.
 

Users who are viewing this thread

Top