SQL2005 查询

来源:百度知道 编辑:UC知道 时间:2024/06/07 02:32:58
1 题目:在SQL Server的股市交易数据库中,给定表A中有两个字段ID、LastUpdateDate,ID表示交易号,LastUpdateDate表示交易时间,请使用一句SQL语句获得最近的交易号。

2 题目:创建一个存储过程,对程序员的工资进行分析,月薪1500-10000不等,如果有一半的人薪水不到6000元,则给所有人加薪,每次加100,在进行分析,直到有一半以上的人大于6000为止,存储过程执行完后,最终交了多少钱?
3 题目:使用一条语句进行数据库分页。
4 题目:假设一个出版社的数据库中有Books和Authors两个表,分别存储书籍信息和作者信息。
1) 请写一句SQL,列出所有作者姓名和其所写书籍的名称。
2) 请写一句SQL,列出写过两本以上(包括两本)书籍的作者姓名。

1,select id from A where lastupdatedate=(select max(lastupdatedate from A))
2,create procedure usp_procedure_name
@total_money output
as
declare @renshu int,@total_renshu int,@cishu int=0
select @renshu=count(*) from table_name where gongzi<6000
select @total_renshu=count(*) from table_name
while @renshu<@total_renshu/2
begin
update table_name set gongzi=gongzi+100
select @renshu=count(*) from table_name where gongzi<6000
select @total_renshu=count(*) from table_name
set @cishu=@cishu+1
end
select @total_renshu=count(*) from table_name
set @total_money=100*@total_t_renshu
3,select top 页大小 * from table_name where id not in(select top 页大小*(页数-1) id from table_name order by id) order by id
4(1)select 作者姓名,书籍名称 from books a,authors b where a.authors_id=b.authors_id;
(2)select 作者姓名,书籍名称 from books a,authors b where a.authors_id=b.authors_id and