3

我正在处理一个查询

列出EMPNAME, PHONE,EMAIL用于获得工资在 30000-50000 之间的临时或兼职员工 - 根据CITY,FACULTY和排列EMPID

我有点困惑,因为我认为当您使用 anorder bygroup by列时需要在 select 语句中列出。

我不确定这应该是什么样子,因为我在做

select empname, phone, email 
 from employee
where emptype = 'PT' 
  and salary between 30000 and 50000
order by city, faculty, empid

一些反馈将不胜感激。

4

2 回答 2

0

您可以按不是所选字段之一的值进行排序。此查询不需要 Group By。下面的查询(基本上是您发布的)将起作用。这假设临时工人和兼职工人都由“PT”标识。

SELECT empname, phone, email 
from employee
where emptype = 'PT' 
and salary between 30000 and 50000
order by city, faculty, empid;

兼职和临时工是否具有相同的 empTpype?

如果没有,你需要这样的东西:

select empname, phone, email 
from employee
where (
      emptype = 'PT' 
      OR
      emptype = 'TEMP'
      ) 
and salary between 30000 and 50000
order by city, faculty, empid
于 2013-08-07T18:53:04.087 回答
0

试试这个查询:

select empname, phone, email from employee
where emptype = 'PT' OR emptype = 'TEMP'
and salary between 30000 and 50000
group by empid order by city, faculty
于 2020-04-24T08:16:15.793 回答