I have a database like this
I try to query the latest job and salary for every employees based on latest s_from_date and t_from_date and concat it to one column "Current Employees"
I try to filter it with max(s_from_date) and max(t_from_date) but it didn’t work
SELECT CONCAT (first_name,' ',last_name,' ',salary,' ',title) As "Current Employees"
FROM employees WHERE s_from_date = (SELECT MAX(s_from_date) FROM employees) AND t_from_date = (SELECT MAX(t_from_date) FROM employees);
2
Answers
if you use phpmyadmin, it can tell where the error position, please see image bellow.
I think you missed "(" after "concat".
You could try
If your
employees
table hasid
/employee_id
column, instead of usinglast_name
andfirst_name
in condition of 2 subqueries, you could change it toe2.id = e1.id
,e3.id = e1.id
.