【正文】
參考解答: 1. 從教學庫中查詢出選修了課程的所有學生信息。 2. 從教學庫中查詢出同時選修了3門課程的全部學生信息。 3. 從教學庫中查詢出每個學生選課的全部情況,并依次按學生號和成績排序。 4. 從商品庫中查詢出每一種商品的商品代號、分類名、數(shù)量和品牌等信息。 5. 從教學庫中查詢出選修2門課程的全部學生。 6. 從教學庫中查詢出學生號為@s1的學生和學生號為@s2的學生所選修的共同課程的課程號。 7. 從商品庫中查詢出所有商品的不同產(chǎn)地。 8. 從教學庫中查詢出被5個以上學生選修的全部課程。 9. 從教學庫中查詢出所有選修了課程的學生信息。 10. select ,單價,數(shù)量,產(chǎn)地 from 商品表1,商品表2 where = 11. select 課程名,成績 from 學生,課程,選課 where = and = and 姓名=39。王明39。 12. select count(*) from 商品表1 where 數(shù)量10 13. select * from 商品表1 where 單價all(select avg(單價) from 商品表1) 14. select * from 商品表1 where 數(shù)量 between 10 and 20 (或where 數(shù)量=10 and 數(shù)量=20) 15. select * from 商品表1 where 數(shù)量=some(select max(數(shù)量) from 商品表1 ) 五、根據(jù)下面所給的AAA數(shù)據(jù)庫,寫出每小題所能實現(xiàn)的功能。 假設(shè)使用名稱為AAA的數(shù)據(jù)庫,它包括Students(學號 char(8),姓名 varchar(8),年齡 int,專業(yè) varchar(20),入學日期 DateTime)和Score(學號 char(8),課程名 varchar(10),成績 numeric(5,2))兩張表。 1. select year(入學日期) as 入學年份,count(*) as 人數(shù) from students group by year(入學日期) 2. declare @a numeric(5,2) set @a=(select avg(成績) from Score) select count(*) as 人數(shù) from Score where 成績=@a 3. select month(入學日期) as 入學月份,count(*) as 人數(shù) from students group by month(入學日期) procedure xxk6 ( @a char(8),@b varchar(10) ) as begin delete from score where 學號=@a and 課程名=@b end 5. create procedure xxk1 as begin select * from students x,score y where = end 6. create procedure xxk6 ( @a char(8),@b varchar(10) ) as begin delete from score where 學號=@a and 課程名=@b end 參考解答: 1. 從Students表中分組統(tǒng)計出每個年份入學的學生人數(shù)。 2. 從Score表中查詢出大于等于平均成績的記錄個數(shù)。 3. 從students表中分組統(tǒng)計出每個月份入學的學生人數(shù)。 4. 從score表中刪除學號為@a的值、課程名為@b的值的學生成績記錄。 5. 顯示出AAA庫中所有學生的記錄信息及選課成績。 6. 從score表中刪除學號為@a的值、課程名為@b的值的學生成績記錄。11