❶ 请问这个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;
说明:因为你没说明表结构,只能写成这样的了。
---
以上,希望对你有所帮助。