I'm currently trying to write an SQL statement which does the following;
"The sales department now uses the abbreviation SL instead of SA. Change the abbreviation in the job description. Select all employees of the sales department except Taylor. Sort by the total."
This is the code i'm currently trying to run, any advice?
SELECT CONCAT("first_name","", "last_name")
FROM employees NOT "Taylor"
WHERE = "sl"
ORDER by verschil DESC
CodePudding user response:
You have not stated which DMBS you are using. But you have a few obvious syntax errors.
- You need to specify the column name for the department in the WHERE clause such as
SELECT ... FROM ... WHERE column_name = "sl" ORDER BY...;
- I would suggest you also include your logic for excluding the person called "Taylor" inside the WHERE clause.
CodePudding user response:
First of all, I am assuming you're working with postgresql, secondly you're trying to get all employees name from employees table who are from sales department (you need to replace column_name1 with the actual name of the column where 'SL' value is inserted, replace column_name2 by the name of the column by which you want the result to sort on).
select first_name, last_name
from employees
where first_name<>'Taylor' and last_name<>'Taylor' and column_name1='SL'
order by column_name2
CodePudding user response:
This should fix your issue :
SELECT first_name," ",last_name
FROM employees
WHERE = "sl" and NOT "Taylor"
ORDER by verschil DESC