SQL查询语句, help me pls
发布网友
发布时间:2022-04-09 21:39
我来回答
共2个回答
热心网友
时间:2022-04-09 23:08
我测试了一下,如下可以运行并得出结果:
employeetable 表:e_id,e_name,e_salary,c_id
company 表:c_id,c_name,c_shuilv
create table company(
c_id number primary key,
c_name varchar2(20) not null,
c_shuilv number
);
insert into company values(1,'xinyu',6000); --结果
insert into company values(2,'wuliao',2000);
insert into company values(3,'IBM',3000);
create table employeetable(
e_id number primary key,
e_name varchar2(20) not null,
e_salary number,
c_id number references company(c_id)
);
insert into employeetable values(1,'张三',3000,1);
insert into employeetable values(2,'poly',5000,1);--max
insert into employeetable values(3,'xiao',1000,2);
insert into employeetable values(4,'naruto',1500,2);
insert into employeetable values(5,'dantin',3000,2);--max
insert into employeetable values(6,'nilu',3000,3);
insert into employeetable values(7,'nimo',2000,3);
insert into employeetable values(8,'kaier',6000,3);--max
查询出每个公司员工月薪最高人的工资。
select max(e.e_salary) from employeetable e group by e.c_id;
=============================================================
此为正确sql:
select c.c_name from company c where c.c_shuilv>(select max(e.e_salary) from employeetable e where c.c_id=e.c_id group by e.c_id);
热心网友
时间:2022-04-10 00:26
select 公司
where sum(税)>max(工资)
group by 公司