0

I have the following query in mysql, and was wondering how I could insert multiple aliases at the same time, any help would be great!

mysql> 
SELECT emp_no,ROUND( AVG(salary), 2),DATE_FORMAT(NOW(),'%m-%d-%Y') AS Today 
FROM salaries 
GROUP BY emp_no 
LIMIT 10;

COLUMN HEADINGS:

| emp_no | ROUND( AVG(salary), 2) | Today      |

I'd like to have something like

| emp_no | avgSal | Today      |
0

1 Answer 1

3

You have already done it for date, just need to add another one for average salary.

SELECT emp_no,
ROUND( AVG(salary), 2) as avgSal,
DATE_FORMAT(NOW(),'%m-%d-%Y') AS Today 
FROM salaries 
GROUP BY emp_no 
LIMIT 10;
Sign up to request clarification or add additional context in comments.

1 Comment

Note the keyword 'AS' is optional. You can omit it if you want for readability/preference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.