手電筒sql
A. 求以下sql答案
1. select distinct Student,ClassCode from Student 2. select ClassCode (as) 『班級號' , DepartmentCode '系部號' , ClassName '班級名' from Class 3. select ClassName , CourseName from Course where ClassNO > 10 4. select Max(Counts) ,avg(Counts) from Course -------counts代表人數字談指段 5. select Teacher , CourseNO , CourseName from Course 6. select CourseName from Course where CountsLimited >= 5 and CountsLimited <= 10 7. select CourseName , Teacher from Course where CountsLimited < avg(CountsLimited) 8. select Teacher , Counts from Course where avg(Counts) < 25 9. 第九題我暫時沒想出來簡單的方法,只寫了一個存儲過程,通過執行存儲過程來返回值,需要的話你加我qq我發給你 10. select distinct CourseName from Course where CourseName = WillOrder 11. select StudentCode ,ClassCode ,ClassName ,VolunteerCode ,Index from Course where ClassCode = '20000003' 12. select Department from Course where ClassCode = '20000003' 13. select bill_id(假設bill_id為該表的主鍵) from Course where StudentCode = '00000005' and Cause = '中餐菜李悉餚製作' delete from Course where bill_id = ???(前面select查詢出來的bill_id) 或者兩條語句合並為 delete from Course where bill_id = (select bill_id(假設bill_id為該表的主鍵) from Course where StudentCode = '00000005'哪侍乎 and Cause = '中餐菜餚製作' ) 14. update Course set CourseName = 'Linux操作系統' where Class = '00電子商務' and Student = '林斌' and CourseName = 'Java技術的開發應用' 15. insert into NewCourse select * from Course where counts < 10
B. 用SQL語句完成下列操作: 將選課在5門課程以上(包括5門)的學生 為什麼用分組 然後在滿足條件寫,不用篩選
原因很簡單 價格的話 不用匯總直接剔除 也就是你說的篩選
而選課在5門以上的話 這個需要匯總 操作後才能判斷 是否符合需求 所以要用分組求出滑歲 每個學生的選課數 再通過having count 篩選
不老讓物明白可以隨時問我 希侍液望採納
C. sql語句求助 查詢選修課沒有不及格科目的學生
select * from [學生成績表] where [選修課1] > 60 and [選修課2] >孝明 60 and [選褲慎皮修課3] > 60 .....
如果你有超過3門選修課,可以繼續再後面添加條件。
如果有個成績胡差欄位,那沒有不及格的:select * from [成績表] where 成績 >60
D. 怎麼寫下面這條sql的語句,新學的沒有答案,請高手幫忙解決
1.update 選課 set 成績=成績+5 where 課程號 in (select 課程號 from 課程 where 課程名="資料庫"
2.update 選課 set 成績=0 where 課程號="2"
3.update 選課 set 成績=85 where 學號 in (select 學號 from 學生 where 姓名="李勇"
4.delete from 選課 where 課程號="2" and 成績 is null
5.delete from 課程 where 課程號 not in (select 課程號 from 選課)
6.delete from 選課 where 課程號 in (select 課程號 from 課程名="資料庫") and 學號 in (select 學號 from 學生 where 系名="計算機")
7.select 系名,sum(*) as 人數 from 學生 group by 系名,性別 into table 學生分類
8.select 學號,count(*) as 課程數,avg(成績) as 平均成績 from 選課 where avg(成績)>=80 into table 成績槐滲肢表
9.create view 無選修 as select 學號,姓名,系鉛世名 from 學生 where 學號 not in (select 學號 from 選課)
select * from 無選修
10. create view 成績 as select 姓名,課程名,成績 from 學生,課程,選課 where 學生.學號=選課.學號 and 選課.課程號=課程.課程號
select * from 成績
11.create view 平均 as select 課程號,count(*) as 選課人數,avg(成績) as 平均分,max(成績) as 最高分 from 選課 group by 課程號
select 選課人數,平均分,最高分 from 平均 where 課程號="1"
12.create view 平均1 as select 學號,成績 from 選課 where 課程號="2" and 成績>(select avg(成績) from 選課 where 課程號="喊旦2")
E. 資料庫期末考試題 求答案 急!
--1
create database 學生選課系統
on primary
(name = 學生選課系統_data,
filename='d:\aa\學生選課系統.mdf',
size=8,
maxsize=100,
filegrowth=20%)
log on
(name =學生選課系統_log,
filename = 'e:\ee\學生選課系統.ldf')
--2
create table 學生
(學號 char(10) primary key,
姓名 char(20),
性別 char(2) check (性別 in('男','女')),
年齡 int default 20,
所在系 char(20))
--3
select 學號,年齡
from 學生
where 所在系='物理系'
--4
select 學號,成績
where 課程號='2'
order by 成績 asc,學號 desc
--5
select 學生.學號 學號,姓名,選修的課程名,成績
from 學生,課程,選課
where 學生.學號=選課.學號 and 課程.課程號=選課.課程號
--6
insert into 學生(學號,姓名,所在系)
values('96002','張三','英語系')
--7
update 學生 set 年齡=年齡+3
--8
delete from 學生
where 所在系='化學系'
--9
create view 英語系學生
as
select 學號,性別,年齡
from 學生
where 所在系='英語系'
--10
create unique index IX_課程號 on 課程(課程號)
--11
create trigger trig1 on 學生
for delete
as
declare @SID char(10)
select @SID=學號 from deleted
begin
delete from 選課 where 學號=@SID
end