求学资讯 oracle认证 提问
oracle认证 > 知识考点

Oracle性能调优:数据库-select查询语

来源:用户上传 上传用户:zhongzhanen 发布时间:2018-05-11

导读:
想要第一时间获得Oracle认证考试报考信息,想要充分利用各种精华资讯资源备考,想要海量高质量、高含金量的习题练习,关注“求学快递网”公众号,你不能错过的考试利器!

  1.在面试过程中多次碰到两道SQL查询的题目,一是查询A(ID,Name)表中第31至40条记录,ID作为主键可能是不是连续增长的列。

  select id,name from

  (select id, name,rownum r from A) t

  where t.r>30 and t.r<41;

  升级版:将表A(id,name)按id升序排列,并取出第6至10行的记录。

  select id ,name from

  (

  select id,name,rownum r from

  (

  select id,name from A order by asc

  )

  )where r>5 and r<11;

  2.SQL语句面试题,表内容如下:

  2005-05-09 胜

  2005-05-09 胜

  2005-05-09 负

  2005-05-09 负

  2005-05-10 胜

  2005-05-10 负

  2005-05-10 负

  如果要生成下列结果,该如何写sql语句

  胜 负

  2005-05-09 2 2

  2005-05-10 1 2

  解:

  create table t (

  t_date verchar2(10),

  score verchar2(2),

  );

  insert into t values ('2005-05-09','胜');insert into t values ('2005-05-09','胜');

  insert into t values ('2005-05-09','负');insert into t values ('2005-05-09','负');

  insert into t values ('2005-05-10','胜');

  insert into t values ('2005-05-10','负');insert into t values ('2005-05-10','负');

  select t_date, 胜,负 from

  (select t_date,count(*) 胜 from t where score='胜' group by t_date) t1

  join (select t_date,count(*) 负 from t where score='负' group by t_date) t2

  on(t1.t_date=t2.t_date);

声明:本站为免费网络服务提供商,网站所有信息均为用户自行发布并由用户承担相应法律责任,本站不对其真实性及合法性负责,如涉及侵权或者信息违法,请你及时与本站联系删除。

阅读 1077 举报

相关推荐
评论0

当前没有评论内容

发表评论 0条评论
91
微博
QQ
QQ空间
微信
取消