① 一道sql语句的题目
1.select t1.姓名,t1.学号,sum(t2.成绩 )/count(t1.学号)as 平均成绩 from 学生表 t1
inner join 选课表 t2 on t1.学号=t2.学号
2.select t1.课程编号,t1.课程名,count(t2.学号)as 人数 from 课程表 t1
inner join 选课表 t2 on t1.课程编号=t2.课程编号
② sql语句12道题谢谢谢啦
如果表MZRZB中不存在字段iJHBS,则修改表,增加字段。
if not exists ( 。。。) 是用来判断的,如果为真,则执行后续的语句。
select b.* from sysobjects a join syscolumns b on a.id = b.id where a.name ='MZRZB' and b.name = 'iJHBS' 是根据系统视图,获取指定表的指定字段名的数据行。
alter table MZRZB add iJHBS INT null 修改表,增加一个字段。
③ 关于SQL语句题
select a.职工号 from works as a,works as b
where a.职工号=b.职工号 and
a.公司名=c2 and b.公司名=c5 and a.职工号 in (select 职工号 from works group by 职工号 having count(公司号)>=2 )
我看你的信息了,但我们学校的网不能直接回,在这里给你回一下!
上面你做的意思是把一个变量同时赋两个值,这当然是不行的了,是吧?
再有问题把你的QQ给我,我们可以交流一下!
我的QQ问题的答案我忘了,所以你加不上我,只有把你的给我,OK!!
④ sql语句的题目
典型的行列转置问题:
select 日期,sum(case when 胜负='胜' then 1 else 0 end) 胜,
sum(case when 胜负='负' then 1 else 0 end) 负
from 表
group by 日期
⑤ SQL语句题目
(5)A
(6)B
1.create index IDX_Readers_1 on Readers(Rname asc);
create index IDX_Books_1 on Books(Btitle desc)
4,5不知道表结构及表之间的主键外键关系就不写了
6.insert into readers(id,name,type) values ('200406002','路宏','2');
任务2:查询总量select count(1) from books;(如果books表无重复记录)
group by 出版社即可按出版社分组;
任务三:不知道表结构就不写sql了
⑥ sql语句 面试题
A.创建表格CODE省略
注明:学生表PK stu_id 课程表pk cos_id 分数表PK enrollment_id FK stu_id,cos_id
B.插入数据code省略
C.Query
select s.stu_id,stu_name,count(cos_id) from student s,enrollments e where s.stu_id = e.stu_id and e.grade>60 group by s.stu_id,stu_name;
select e.stu_id,s.stu_name,c.cos_name from student s,enrollments e,course c
where s.stu_id = e.stu_id
and e.cos_id = c.cos_id
and c.cos_name = 'CHINESE'
and s.stu_name like 'W%';
select stu_id,stu_name from (select e.stu_id,stu_name,cos_name from enrollments e,student s,course c
where s.stu_id = e.stu_id
and e.cos_id = c.cos_id
and c.cos_name IN ('CHINESE','MUSIC'))
group by stu_id,stu_name
having count(cos_name) = 2
select distinct e.cos_id,c.cos_name,count(e.stu_id) stu_count,count(e.stu_id)-NVL(A.FAIL,0) upscore,(count(e.stu_id)-NVL(A.FAIL,0))/count(e.stu_id) rate from
(select cos_id,count(stu_id) fail from enrollments where grade<60 group by cos_id) a,enrollments e,course c
where e.cos_id = a.cos_id(+)
and e.cos_id = c.cos_id
group by e.cos_id,NVL(a.fail,0),c.cos_name;
update student
set avg_grade =(select avg(grade) X from enrollments group by stu_id
having student.stu_id = enrollments.stu_id);
select stu_id,avg(grade) from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)
group by stu_id
having count(*)<=2
UNION
select A.stu_id,avg(A.grade)from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments) A,
(select stu_id,count(*) c from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)
group by stu_id) B
where A.stu_id = B.stu_id
and A.x>1 and x<B.c
group by A.stu_id,b.c
_________________________________________________
环境:oracle 10g/TOAD 以上代码均通过测试,如有问题,请联系,谢谢
⑦ sql语句 大侠们看看这道题目该怎么做啊
1.
create database 学生成绩数据库课程信息表成绩信息表
2.
use 学生成绩数据库课程信息表成绩信息表
create table 宿舍表
(宿舍号 char (6) primary key,
宿舍电话 char(7) check(left(宿舍电话,3)='633')
)
3.
create table 同学表
(学号 char(6) primary key,
姓名 nvarchar(10) not null,
性别 nvarchar(1) check(性别='男' or 性别='女'),
年龄 int not null,
民族 nvarchar(10) default ('汉') not null,
身份证号 char(18) unique,
宿舍号 char(6) foreign key references 宿舍表(宿舍号)
)
4. ……
………………
……
⑧ 写sql语句的题目
update gl_coa_acc set acc_code='110'||to_char(to_number(substr(acc_code,4,3))+10084)
where acc_code like '135%';
至于2-2部分根据需要按照相同方式追加就可以了。
问题2要求不合理,没有必要通过存储过程创建表,并输入记录的。
创建表:create table myuser(mname varchar2(8),mage int,mzw varchar2(10),mqx varchar2(10));
查找年龄大于18的所有信息语句:select * from 表名 where 年龄>18;
⑨ 数据库检索SQL语句题目求 解答
1、select 图书编号,书名,定价 from 图书 where 出版社标号='CS';
2、select 图书.书名,图书.定价,出版社.出版社名称 from 图书,出版社 where 图书分类='教材' and 图书.出版社编号=出版社.出版社编号;
3、select 出版社编号,count(图书编号),avg(定价) from 图书 group by 出版社编号;
4、select 图书.图书编号,图书.书名 from 图书,出版社 where 图书分类='教材' and 图书.出版社编号=出版社.出版社编号 and 出版社.出版社编号=‘高等教育出版社’ and 图书.定价>30;
⑩ 问一道SQL语句的题目,请各位帮帮忙。
1,select 任课教师 ,开课系
from 课程表
where 任课教师 =‘李老师’
2,select 学生表.学号 ,学生表.姓名
from 学生表,学习表, 课程表
where 学生表.学号= 学习表.学号
and 学生表.年龄 >=19
and 学生表.性别 = ‘女’
and 学生表.所在系= ‘计算机’
3,select 学生表.姓名
from 学生表,学习表, 课程表
where 学生表.学号= 学习表.学号
and 课程表.课程号 = 学习表.课程号
and 学生表.性别 = ‘女’
and 课程表.课程号 not in (select 课程号
from 课程表
where 任课教师 =‘刘老师’)
4,select 课程表.课程号,课程表.开课系
from 学生表,学习表, 课程表
where 学生表.学号= 学习表.学号
and 课程表.课程号 = 学习表.课程号
and 学生表.姓名 = ‘王乐’
5,select 学生表.学号,学生表.姓名
from 学生表
where 学生表.学号 in (select 学生表.学号,count(学号) as 修读门数
from 学习表
group by 学习表.学号
having 修读门数>=3)
6,select count(*) from((select 学生表.姓名
from 学生表
where not exists
(select 课程好
from 课程表
where not exists
(select *
from 学习表,学生表,课程表
where 学习表.学号= 学生表.学号
and 学习表.课程号= 课程.课程号))
7,select count(学生表.学号)
from 学生表
where 学生表.所在系= ‘计算机’
8,select 课程表.课程号,课程表.课程名,avg(学习表.成绩)
from 学生表,学习表, 课程表
where 学生表.学号= 学习表.学号
and 课程表.课程号 = 学习表.课程号
and 课程表.课程系 = ‘计算机’
group by 课程表.课程号,课程表.课程名
9,select 学生表.学号,学生表.所在系
from 学生表,
where 学生表.姓名 like ‘张%’
and 学生表.姓别 = ‘男’
10 update 学习表
set 学习表.成绩=null
where 课程表.课程号 = 学习表.课程号
and 课程表.课程名 = ‘数据库原理课’
and 学习表.成绩 <='69'
以上答案请你参考,由于时间原因,有不准确的请你谅解