當前位置:首頁 » 編程語言 » 用sql語句完成下面各題
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

用sql語句完成下面各題

發布時間: 2022-12-08 17:43:21

① 用sql語句完成下列問題。

1、第一題,是查詢總和,總和在SQL中使用sum,如:select sum(成績) from 表名
2、第二題,查詢平均值,SQl:select 學號,Avg(sum(成績)) from 表名 group by 學號

3、第三題,查詢每課程學生人數,SQL : select 課程名稱,count(學號) from 表名 group by 課程名稱
4、第四題,查詢最高分,也就是最大值,select max(成績),學號 from 表名 group by 學號
5、第五題,查詢每科的最高分,SQL:select max(成績),課程 from 表名 group by 課程 最低分 select min(成績),課程 from 表名 group by 課程 平均分 select Avg(sum(成績)),課程 from 表名 group by 課程
6、第六題 顯示綜合大於250分的信息 SQL: select 學生ID,sum(成績) 總分 from 表名 where sum(成績)>250 group by 學生ID
7、第七題 顯示平均分 SQL:select 學生ID,Avg(sum(成績)),課名 from 表名 where sum(成績)>250 group by 學生ID,課名 order by Avg(sum(成績)) asc
8、第八題 查詢人數 SQL:select 課程ID,sum(學生ID) from 表名 where sum(學生ID)>=30 group by 課程ID
9、第九題 查詢最高分 SQL:select max(成績),課程,學生名字 from 表名 where max(成績)>=90 group by 課程,學生名字
10、第十題 成績>=60,平均分>85 SQL:select 學生 from 表名 where avg(sum(成績))>85 and min(成績)>=60 order by avg(sum(成績)) desc

好辛苦,望採納

② 使用SQL語句完成 下列題;

1. delete 表名 where 列名=列的值
2.update 表名 set 列名=列的值 where 列名=列的值
3. insert into 表名(列名) values (列的值)
4. select * from 表名
5. select 系的列名 from 表名 where 姓名的列名=張三'
6. select 課程的列名 from 表名 where 姓名的列名=李四'
7. select 學生姓名的列名 from 表名 where 年齡的列名>18 and 年齡的列名<22
8.select * from 表名
最基本的用法可以在:我的博客上看 http://blog.csdn.net/wangganggang90/article/details/6925847

③ 用SQL語句完成下列操作要求

1.insert into stuinfo(stuid,stname,sex,nation,class,address) values(2015121226,張三,男,白族,15計算機網路,雲南大理);
2.delete course where cname='foxpro應用基礎';
3.select stname as 姓名,round(to_number(to_char(sysdate,'yyyy')-to_char(birthdate,'yyyy'))) as 年齡,class as 班級 from stuinfo where round(to_number(to_char(sysdate,'yyyy')-to_char(birthdate,'yyyy')))>=20;
4.select st.stuid as 學號,st.stname as 姓名 from stuinfo st inner join course c on c.cid=st.stuid inner join score sc on sc.cid=c.cid where sc.score in (select max(score) from score);
5.select st.stuid as 學號,st.stname as 姓名,c.cname as 課程名稱,sc.score as 成績 from stuinfo st inner join course c on c.cid=st.stuid inner join score sc on sc.cid=c.cid;
6.select st.stname as 姓名 from stuinfo where address in (select address from stuinfo where stname='張三');
7.select stname as 姓名,to_char(sysdate,'yyyy')-to_char(substr(zjh,7,4)) as 年齡 from stuinfo
8.create or replace procere stmax
as
fs nvarchar2(200);
mz nvarchar2(200);
begin
select c.cname into mz,sc.score into fs from course c inner join score sc on sc.cid=c.cid group by c.cname;
DBMS_OUTPUT.put_line(mz||':'||fs);
end;
9.觸發器略過
10.略
11.update course set cname='資料庫原理與應用' where cname='資料庫原理';
12.select * from stuinfo where stname like '張%';
13.select * from stuinfo where nation !='漢族';
14.select c.cname,AVG(sc.score) from course c inner join score sc on sc.cid=c.cid group by c.cname;

累死,望採納

④ 請求解題 要求用SQL語句完成下列題目

按圖中問題和需求,以下會使用mysql環境的sql進行解答。

  • 第一題: 考察主鍵和外鍵的創建表語句,以及基本的創建語句格式。這里提供兩種,其餘可以查閱相關資料。

mysql 插入數據

⑤ 用sql語言完成下列問題

第一題:
use stu
go
create table Student(
學號 int,
姓名 varchar(10),
性別 varchar(2),
年齡 varchar(3),
所屬系 varchar(20)
)

第二題:
use stu
go
select 學號 from SG where 成績<60

第三題:
use stu
go
select 姓名,年齡,性別 from Student where 姓名 like ' 張%' and 性別 = '男' and 所在系='計算機系'

第四題:
use stu
go
insert into Student
values
(05020,'姓名','高平','女','19歲','經濟管理系')

⑥ 用SQL語句完成以下操作。

1
insert into 學生.DBF(學號,姓名,性別) values('10359999','張三','男')
2
update 學生成績.DBF set 成績=null where 課程.DBF.課程編號=學生成績.DBF.課程編號 and 課程.DBF.課程名稱='計算機' and 學生成績.DBF.成績<60
3
update 學生成績.DBF set 成績=成績 + 20 where 課程編號='01'
4
select 學號,姓名,年齡 from 學生.DBF where DateDiff('yyyy',出生日期,getDate())=22

⑦ 用SQL語言完成下面四個問題,謝謝大家了!

1 select 職員號 from 訂單 group by 職員號 having count(職員號)>3 and avg(金額)>200
2 select 職員號,姓名 from 職員 where 職員號 not in (select 職員號 from 訂單)
3 delete from 訂單 where 客戶號=1001
4 update from 訂單 set 金額=169 where 訂單號='0060'