--插入表pm_stu數(shù)據(jù)
insert into pm_stu (STU_ID, STU_NAME)
values ('1', '張三');
insert into pm_stu (STU_ID, STU_NAME)
values ('2', '李四');
insert into pm_stu (STU_ID, STU_NAME)
values ('3', '王五');
insert into pm_stu (STU_ID, STU_NAME)
values ('4', '趙六');
insert into pm_stu (STU_ID, STU_NAME)
values ('1', '張三');
insert into pm_stu (STU_ID, STU_NAME)
values ('2', '李四');
insert into pm_stu (STU_ID, STU_NAME)
values ('3', '王五');
insert into pm_stu (STU_ID, STU_NAME)
values ('4', '趙六');
2019-04-03
--插入表pm_ci數(shù)據(jù)
insert into pm_ci (CI_ID, STU_IDS)
values ('1', '1,2,3,4');
insert into pm_ci (CI_ID, STU_IDS)
values ('2', '1,4');
insert into pm_ci (CI_ID, STU_IDS)
values ('1', '1,2,3,4');
insert into pm_ci (CI_ID, STU_IDS)
values ('2', '1,4');
2019-04-03
--建表語句
create table pm_ci
(
ci_id VARCHAR2(20) not null,
stu_ids VARCHAR2(100)
);
create table pm_stu
(
stu_id VARCHAR2(20) not null,
stu_name VARCHAR2(100)
);
create table pm_ci
(
ci_id VARCHAR2(20) not null,
stu_ids VARCHAR2(100)
);
create table pm_stu
(
stu_id VARCHAR2(20) not null,
stu_name VARCHAR2(100)
);
2019-04-03
select 課程名, wm_concat(學(xué)生姓名|| '、') 選課學(xué)生 from
(select * from
(select c.ci_id 課程名, s.stu_name 學(xué)生姓名,
instr(c.stu_ids, s.stu_id) choose
from pm_ci, pm_stu s
where instr(c.ci_id, s.stu_name) is not null)
where choose=1) group by 課程名;
(select * from
(select c.ci_id 課程名, s.stu_name 學(xué)生姓名,
instr(c.stu_ids, s.stu_id) choose
from pm_ci, pm_stu s
where instr(c.ci_id, s.stu_name) is not null)
where choose=1) group by 課程名;
2019-03-01
select a.CI_ID,to_char(
(select wm_concat(decode(instr(a.stu_ids,b.stu_id),0,null,b.stu_name))
from pm_stu b
)
) STU_NAME
from pm_ci a where a.ci_id is not null;
(select wm_concat(decode(instr(a.stu_ids,b.stu_id),0,null,b.stu_name))
from pm_stu b
)
) STU_NAME
from pm_ci a where a.ci_id is not null;
2019-02-15
select a.CI_ID,to_char(
(select wm_concat(decode(instr(a.stu_ids,b.stu_id),0,null,b.stu_name))
from pm_stu b
)
) STU_NAME
from pm_ci a;
(select wm_concat(decode(instr(a.stu_ids,b.stu_id),0,null,b.stu_name))
from pm_stu b
)
) STU_NAME
from pm_ci a;
2019-02-15
select b1.cid,wm_concat(b1.sname) from
(select c.ci_id cid,s.stu_name sname,instr(c.stu_ids,s.stu_id)
from pm_ci c,pm_stu s where instr(c.stu_ids,s.stu_id)<>0) b1 group by b1.cid;
(select c.ci_id cid,s.stu_name sname,instr(c.stu_ids,s.stu_id)
from pm_ci c,pm_stu s where instr(c.stu_ids,s.stu_id)<>0) b1 group by b1.cid;
2019-01-06
select p.ci_id,max(stu_name) as STU_NAME
from (select c.ci_id,wm_concat(s.stu_name)
over(partition BY c.stu_ids order by s.stu_id) as stu_name
from pm_ci c,pm_stu s
where instr(c.stu_ids,s.stu_id) > 0) p
group by p.ci_id;
from (select c.ci_id,wm_concat(s.stu_name)
over(partition BY c.stu_ids order by s.stu_id) as stu_name
from pm_ci c,pm_stu s
where instr(c.stu_ids,s.stu_id) > 0) p
group by p.ci_id;
2019-01-03