oracle初学者求5条sql的语句~~有附加分

Employee(EID, Fname, Lname, Address, DOB, Gender, Salary, Bonus, DID)
Department(DID, Name, Mgr_EID, Mgr_Start_Date)
Project(PID, Name, DID)
Work_On(EID, PID, Hours)
这些是表格,
(9)多少Employee住在London
(10)每个Department中Male和Female的数量
(11)求找到employee中salary的最大值,最小值,平均值
(12)求每个Department中employee的数量和他们的salary的sum
(13)找出那个Department中employee的数量最少?

9、
select count(EID) from Employee where Address='London';
10、
select A.DID,D.Name,A.Male,B.Female from
(select D.DID,sum(Gender) Male from Employee where Gender='Male' group by DID) A,
(select D.DID,sum(Gender) Female from Employee where Gender='Female' group by DID) B,
Department D
where A.IDI=B.DID and B.DID=D.DID;
11、
select max(Salary),min(Salary),avg(Salary) from Employee;
12、
select D.DID,D.Name,sum(E.EID),sum(E.Salary) from
Department D,Employee E where D.DID=E.DID group by D.DID,D.Name;
13、
select * from Department where DID =(select DID from (select DID,sum(EID) as 数量 from Employee group by DID order by 数量) where rownum <=1);

---
以上,希望对你有所帮助。
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-05-18
(9)多少Employee住在London
select count(EID) from Employee where Address='London '
(10)每个Department中Male和Female的数量
select count(Gender) from Employee where Gender='Male' group by DID
(11)求找到employee中salary的最大值,最小值,平均值
select max(Salary),min(Salary),avg(Salary) from Employee
(12)求每个Department中employee的数量和他们的salary的sum
select DID,count(employee) ,SUM(salary)from Employee group by DID(13)找出那个Department中employee的数量最少?
SELECT TOP(1) FROM(select DID,count(employee)from Employee group by DID ORDER BY count(employee))

怎么写SQL语句,oracle每个类别只取五条数据
select * from (select t.*,row_number() over(partition by group_column order by order_column) rn from table t )where rn <=5 ;分组以及排序条件按照你的需求修改。

怎么写SQL语句,oracle每个类别只取五条数据
select 类别,其他字段, row_number() over (partition by 类别 order by 某个排序字段) rn from table_name ) t where rn<=5

每种类型取5条数据,sql语句怎么拼? sql
select top 5 * from TableName where Type=1 union select top 5 * from TableName where Type=2 ...有几种类型接着往后加,用union连接就可以了。如果你的类型非常多,不能一个一个写,那就不能是一句sql语句的事了。

oracle sql语句相关问题,分组后查询。
首先,你提的问题有些疑惑,你要d字段统级次数最多的前5个数据,照你这句话,查询出来的结果集应该是大于等于5行数据的.比如 select * from (selct d,count(1) as top5 form t group by d order by top5 desc) a where rownum<=5。查出的结果集可能为:d top5 x 10 y 9 z...

oracle数据库里分页sql怎么写啊,要求一页显示5条,一共21页.sql应该怎 ...
SELECT FROM (SELECT a.*, ROWNUM rn FROM (SELECT * FROM zs_family) a WHERE ROWNUM <= 105)WHERE rn BETWEEN 1 AND 5;-- 1 AND 5 采用动态SQL传参就行。下一页就是6到10,直到101到105

oracle 求sql语句 按照日期范围分组查询。请务必写出测试过的代码,有难...
create table test(startdate date,enddate date,autualdate date,"desc" varchar2(10),"value" int)--插入数据 insert into test values (to_date('2013-05-17','yyyy-mm-dd'),to_date('2013-05-17','yyyy-mm-dd'),to_date('2013-05-17','yyyy-mm-dd'),'a',100);insert into ...

Oracle中的SQL查询语句:包含表一所有数据,根据表二中的某一字段的不同...
sleect a.部门,sum(case when b.正负 = 'Y' then b.分值 else 0 end) 正分,sum(case when b.正负 = 'N' then b.分值 else 0 end) 负分 from table1 a,table2 b where a.id = b.id(+)group by a.部门 右关联就好了,你试下,谢谢!

sql 语句查询 前5名后5名的成绩
利用排序,找到每个人的位置,然后输出。排序的方法很多,可以用rownum排序,也可以用row_number()over()排序 我用row_number()over()写一个 select a.姓名,a.成绩 from (select row_number()over(order by 成绩) num,姓名,成绩 from table) a where a.num<=5 or a.num>=(select count(*)...

100分求条不太难的SQL语句,速度
不知道这样行不行,反正oracle里这样是可以的了 select * from Game where gameid not in (select gameid from gamerecord where studentid=4);或者 select * from Game a where not exists (select 1 from gamerecord b where b.studentid = 4 and a.gameid = b.gameid);...

oracle的sql语句
你很高啊,答案很明显;第一条语句可以解释为 select * from orders where ordercode in ('FH-ZD-1324052,FH-ZD-1323759,FH-ZD-1323753,FH-ZD-1323751,FH-ZD-1323748,FH-ZD-1323722');你可以自己比较一下和第二条语句的区别了...

相似回答
大家正在搜