① 一道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'
以上答案請你參考,由於時間原因,有不準確的請你諒解