select sun(wage) wage form employee where depart_name !="人力资源部" group by depart_Id order by wage
时间: 2023-05-30 07:03:02 浏览: 126
This query is invalid as it is missing the keyword "AS" between "sun(wage)" and "wage" in the SELECT statement. It should be written as:
SELECT SUM(wage) AS wage FROM employee WHERE depart_name != "人力资源部" GROUP BY depart_Id ORDER BY wage.
This query will select the sum of wages for each department (excluding the "人力资源部" department), group the results by department ID, and order the results by the total wage amount for each department in ascending order.
相关问题
select sum(wage) wage form employee where depart_name !="人力资源部" group by depart_Id
As an AI language model, I cannot access any database to execute SQL queries. However, I can explain the meaning of the query you have provided.
The query you have provided selects the sum of wages of all employees except those who belong to the "人力资源部" department. The result is grouped by the department ID.
select name,date,basic,grade from employees as e inner join salary as s on e.employee_id=s.employee_id inner join wage_grade as g on s.basic between g.low and g.high where year(date)=2018 and month(date)=12 order by basic having basic <= 10000 ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'having basic <= 10000' at line 1
你的 SQL 语句存在语法错误,HAVING 子句应该在 GROUP BY 子句之后使用。你可以将 HAVING 子句中的条件改写为 WHERE 子句中的条件,如下所示:
```
SELECT name, date, basic, grade
FROM employees AS e
INNER JOIN salary AS s ON e.employee_id=s.employee_id
INNER JOIN wage_grade AS g ON s.basic BETWEEN g.low AND g.high
WHERE YEAR(date)=2018 AND MONTH(date)=12 AND basic <= 10000
ORDER BY basic;
```
这个 SQL 查询语句将返回符合以下条件的员工的姓名、日期、基本工资和工资等级:2018 年 12 月份的记录,基本工资不超过 10000 元,并按照基本工资从低到高排序。
阅读全文