當前位置:首頁 » 編程語言 » sql最近一次考試怎麼寫
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql最近一次考試怎麼寫

發布時間: 2022-12-22 00:05:26

❶ 請問這個sql語句要怎麼寫,要求盡量簡潔

select id,name,modify_time
from (
select id,name,modify_time,
row_number() over(partition by name order by modify_time desc) as rn
from table_name
) t
where rn<=1

❷ 怎麼寫sql 查詢近一年的記錄

1. 首先,我們需要創建一個新的數據表並准備一些數據。


資料庫SQL語句考試

1.
create table A (
S# varchar(20) primary key,
SN varchar(20),
Sex varchar(2),
Age number(10),
Dept varchar(50));
create table B (
C# varchar(20) primary key,,
CN varchar(20));
create table C (
S# number(10),
C# number(10),
Grade number(10));
2.
insert into table A(S#,Sn,Dept) values('010102','張靜','機電');
3.
update C set grade=59 where grade>=60;
4.
delete * from C where S# in (select S# from A where Sn like '李%');
delete * from A where Sn like '李%';
5.
select S#,Sex,Age from A where Sn='劉華';
6.
select A.S#,B.C#,B.Cn from A,B,C
where A.Dept not in('計算機系','法律系') and A.S#=C.S# and C.C#=B.C#;
7.
select C.S#,sum(Grade) G from B,C
where Cn='大學語文' and B.C#=C.C# group by C.S# order by G desc;
8.
alter table A drop column Sex;//刪除列
alter table A drop Column Age;
update A set SEX='',AGE='';//刪除列記錄
(不知道你這個刪除具體是什麼意思,2種你自己選擇。)
9.
drop table C;
drop table B;
drop table A; //先刪C再刪A,否則會報錯,無法刪除使用記錄。

❹ 求助SQL考試題。。明天早上就考了 今晚要交

1.select 書名,出版社 from 圖書 where 20=<價格=<50 order by 價格 desc
2.select distinct a.書號 as 圖書種類 ,a.操作員帳號 from 借出 a,操作員 b where a.操作員帳號=(select b.操作員帳號 from 操作員 where 操作員姓名='李凡')
3.select 書名,出版社 from 圖書 where 書名 like '%資料庫%' or 書名 like '%SQL%'
4.delete from 課程 where 課程編號 in ( '20016','20018','20019')
5.insert into 教師 (教師編號,姓名,所在部門,職稱) values (60016,王力,,講師)
6.select a.生產廠家,count(b.商品編號) as 商品種類 from 商品 b,(select distinct 生產廠家 from 商品) as a where a.生產廠家=b.生產廠家 group by a.生產廠家

❺ 急!考試要考SQL語句!!不難!會寫的幫忙寫一下!加分!!!!!

1、select 成績 from 表 where 成績>60 order by 成績 asc;
2、
SqlServer:
select top 10 成績 from 表 where 成績>60 order by 成績 desc;
oracle:
select * from (select 成績,row_number()over(order by 成績 desc) id from 表 where 成績>60) where id <=10;
3、insert into table(欄位1,欄位2,欄位3,欄位4) values(5,'rrr','1984-6-7',89);
4、delete from 表名 where 編號=3;
5、update 表名 set 成績=90 where 編號=90;

說明:因為你沒說明表結構,只能寫成這樣的了。
---
以上,希望對你有所幫助。