加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle面试题

发布时间:2020-12-12 15:09:21 所属栏目:百科 来源:网络整理
导读:面试题1 分析:从要求的结果中可以看出,最后一列的数是和上一列斜对着的 主要用到了相关子查询 select t1. id ,t1. name ,t1.money,(select t2.money from test1 t2 where t1. id = t2. id + 1 ) MONEY1 from test1 t1; 面试题2 这里用到了组函数:wm_concat(v

面试题1

分析:从要求的结果中可以看出,最后一列的数是和上一列斜对着的
主要用到了相关子查询

select t1.id,t1.name,t1.money,(select t2.money from test1 t2 where t1.id = t2.id+1 ) MONEY1
from test1 t1;


面试题2


这里用到了组函数:wm_concat(varchar2) instr函数

instr函数的使用:
格式:instr(string1,string2[,start_position[,nth_appearence]])
string1:要在此字符串中查找。

string2:要在string1中查找的字符串。

start_position:从string1开始查找的位置。可选,默认为1,正数时,从左到右检索,负数时,从右到左检索。

nth_appearence:查找第几次出现string2。可选,默认为1,不能为负。

注:如果没有查找到,返回0。
例如:

select instr(‘abcd’,’a’) from dual;  –返回1
select instr(‘abcd’,’c’) from dual;  –返回3
select instr(‘abcd’,’e’) from dual;  –返回0

例如:
 select deptno,wm_concat(ename) nameslist from emp group by deptno;
select ci_id,wm_concat(stu_name) namelist from (select ci_id,stu_name from pm_ci c,pm_stu s where instr(c.stu_ids,s.stu_id) > 0) group by ci_id;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读