日期:2014-05-18  浏览次数:20494 次

小弟菜鸟请高手多多指教,谢谢
表 hpx中有字段theksh(考生号),thexm(姓名),thetime(时间),theflag(1表示已扫描,0表示未扫描),thesocer(分数)。
1、找出该表中前面50条记录
2、向该表中插入一条记录,100(考生号),张三(姓名)
3、把考生号为2432430001000203的考生theflag改为0
4、删除表中考生号为100这条记录
5、列出已扫描的总人数
6、找出表中在2010-09-19 22:36:49之前的记录
7、按时间先后列出所有考生
8、找出表中的总人数
9、找出姓‘李’的所有人
10、将所有记录的考生号字段前面加一个‘0
11、通过语句判断分数划分等级,小于60分为C,大于等于60小于80分为B,大于等于80分为A,列出所有考生的等级
12、自动生成多个字段,如:X1,X2,X3......X100
这12个问题请大家帮忙指点下,小弟是菜鸟中的新手,谢谢

------解决方案--------------------
SQL code

select top 50 * from hpx
insert into hpx (theksh,thexm) values ('100','张三')
update hpx set theflag= 0 where theksh ='2432430001000203'
delete hpx where theksh = 100
select count(*) from hpx where theflag= 1 
select * from hpx where thetime <'2010-09-19 22:36:49' 
select * from hpx order by thetime 
 select count(*) from hpx
select * from hpx where thexm like '%李'
 update hpx set theksh = '0' + cast(theksh as varchar(100))
select theksh,thexm,case when thesocer < 60 then 'C' when thesocer < 80 then 'B' when  thesocer >= 80 then 'A' end
select top 0 'X1' as x1,'X2' as x2,'X3' as x3  into newtab from Sys_User

------解决方案--------------------
SQL code

create table hpx
(
theksh varchar(20),
thexm nvarchar(20),
thetime datetime,
theflag varchar(10),
thesocer varchar(10)
)
1.
select  top  50  * from hpx;
2.
insert into hpx(theksh,thexm) values(100,N'张三');
3.
insert into hpx(theksh) values('2432430001000203');
update hpx set theflag='0' where theksh='2432430001000203';
4.
delete from hpx where theksh='100'
5.
select count(1) [扫描总人数] from hpx where theflag='1'
6.
select * from hpx where thetime<'2010-09-19 22:36:49'
7.
select * from hpx
order by thetime 
8.
select count(1) [总人数] from hpx
9.
select * from hpx where thexm like '李%'
10.
update hpx set theksh='0'+theksh 
11.
select theksh,thexm,thesocer,
case 
when thesocer < 60 then 'C' 
when  thesocer < 80 then 'B' 
when  thesocer >= 80 then 'A' end
from hpx