1、在oracle中有一个表,表中的数据如下: 姓名 课程 成绩 张三 语文 20 张三 数学 30 张三 英语 40 要求用select语句将结果显示为: 姓名 语文 数学 英语 张三 20 30 40 2、在oracle中有个emp表,表中有empid,name,sal(工资)三列数据,现在要求查询工资至少比5个人高的所有人的 empid,name,sal和工资低于他的人数。 3、在oracle中有一个person表,表中的数据如下: id age 001 30 002 36 003 58 004 27 005 58 其中age可以相同,现要求查询age最大的id最小的纪录。
解决方案 »
- 如何获取存储过程参数
- 不显示删除回复显示所有回复显示星级回复显示得分回复 oracle 11g 乱码,执行带中文的sql语句,sql语句中文自动变成乱码,怎么会事啊!
- 错误oracle-12514:TNS:监听程序当前无法识别
- weblogic服务器查询数据异常!
- Oralce 安装后出现这样的提示!!高手请看!
- 问一个SQL的修改语句
- 密码又莫名其妙的丢了
- 本人初次接触orcle,问一个很弱的问题:如何在vc6下通过OO4O访问orcle ?
- 菜鸟问题:oracle客户端配置问题!
- 请教一下,asp访问oracle的问题?
- 高手帮帮忙 谢谢
- oracle 怎么把一个库中的某个表的数据单独回滚到24小时以前??跪求答案
from table
group by 姓名
在oracle中有个emp表,表中有empid,name,sal(工资)三列数据,现在要求查询工资至少比5个人高的所有人的 empid,name,sal和工资低于他的人数。
select a.empid,a.name,a.sal,a.rn-1
from
(select row_number() over(order by sal desc) rn,empid,name,sal
from emp
) a
where rn>5
其中a.rn-1就是工资低于他的人数
是作业吗?总感觉是不是面试题 ...
1: select tt.sna,
max(decode(tt.course,'yuwen',tt.score)) as "yuwen",
max(decode(tt.course,'shuxue',tt.score)) as "shuxue",
max(decode(tt.course,'yiyu',tt.score)) as "yiyu"
from tablename tt
group by tt.sna;
SNA yuwen shuxue yiyu
-------- ---------- ---------- ----------
zhangsan 20 30 402: select tt.empid,
tt.name,
tt.sal,
tt.rn - 1 as "Person_Count"
from (
select e.*,
rank() over(order by e.sal) as rn
from emp e
)tt
where tt.rn > 5;3:select *
from person t3
where exists (
select 1
from person t2
where not exists (select 1
from person t1
where t2.age < t1.age
)
and t3.age = t2.age
and t3.sid < t2.sid
);SID AGE
--- ----------
003 58
from
(
select min(id) id,age
from person
group by age
) a,
(
select max(age) age
from person
) b
where a.age=b.age