永发信息网

数据库基础-SQL查询语句8条,帮忙写下。

答案:2  悬赏:50  手机版
解决时间 2021-02-07 17:22
  • 提问者网友:做自己de王妃
  • 2021-02-06 19:33
—表dbo.dept
——列deptno/dname
—表dbo.emp
——列empno/ename/esex/passcardno/deptno/Hiredate/salary/comm/mgr
查询语句如下:
1.插询每个部门的最高的月工资和部门编号
2.查询员工姓名、员工所在部门名称、员工工资(使用等值连接)
3.查询员工姓名、员工所在部门名称、员工工资(使用左连接)
4.查询“开发部”的员工姓名和月工资
5.查询所有的员工姓名、工资和领导姓名、工资
6.查询男女员工的人数
7.使用union all查询部门编号在2-4之间和员工编号在2-8之间的员工信息
8.创建一个新表newemp,取自emp表的empno,ename,deptno,salary
最佳答案
  • 五星知识达人网友:刀戟声无边
  • 2021-02-06 20:51
1.插询每个部门的最高的月工资和部门编号
查询最高月工资,还要查询最高部门编号?
查询最高月工资的:select deptno,isnull(max(salary),0) as max_salary from emp group by deptno

2.查询员工姓名、员工所在部门名称、员工工资(使用等值连接)
select * from dept,emp where dept.deptno=emp.deptno

3.查询员工姓名、员工所在部门名称、员工工资(使用左连接)
select * from emp left join dept dept.deptno=emp.deptno

4.查询“开发部”的员工姓名和月工资
select * from emp left join dept dept.deptno=emp.deptno
where dept.dname = '开发部'

5.查询所有的员工姓名、工资和领导姓名、工资
员工 同第二题, 领导的加个条件 where mgr=1

6.查询男女员工的人数
select emp.esex,count(*) as '人数' from emp group by emp.esex

7. 如你所说

8.创建一个新表newemp,取自emp表的empno,ename,deptno,salary
select empno,ename,deptno,salary into newemp from emp
全部回答
  • 1楼网友:洒脱疯子
  • 2021-02-06 21:41

1.select  姓名 from 顾客 where 积分 in(select max(积分)  from 顾客)

2.select 名称,电话 from 厂商 where 编号 in

(select 厂商编号 from 商品 where 编号 in(select 商品编号 from 销售 group by 商品编号 having sum(数量)>1000))

3.select * from 厂商 where 编号 in

(select 厂商编号 from 商品 group by 厂商编号 having count(*)>5)

4.select * from 商品 where 编号 not in(select 商品编号 from 销售 )

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯