第三章 SQL编程 课上知识点笔记

--储存 字符串 类型
declare @name nvarchar(32)
set @name ='小雨吧'
print @name

--储存 浮点型 
declare @Blance decimal(18,7)
set @Blance=12.36
print @Blance

--储存 字符串型 
declare @Brithday datetime
set @Brithday='1998-3-30'
print @Brithday

--最后一个T-SQL语句的 错误符号
select @@ERROR 

--输出 计算机的名称
select @@SERVERNAME

--输出 自增列 最后一次插入的标示值
select @@IDENTITY

--cast  convert  转换
declare @num int 
set @num=5
print '值是:'+cast(@num as nvarchar(32))

declare @numm int 
set @numm=6
print '值是:'+convert(nvarchar(32),@numm)

--if-elese 结构
declare @age int
set @age=30
  if(@age=30)
begin 
   print'库里'
end 
 
else
begin 
   print '詹姆斯'
end


--public class student{
--类中的内容都称为成员

--public string name;

--驼峰命名法 Camel  首字母小写,后续有含义的单词,首字母大写 成员变量。
--帕斯卡命名法 Pascal 首字母大写,后续有含义的单词,首字母大写  类名

--public void doHomeWork(){
      --int age=10;  局部变量
	  --生命周期  呱呱坠地------dameover 

-- }
     --public string Play(){
          --rerurn name+"科比布莱恩特";  	 
	  --}

	  --返回到了哪里???
	  --在方法体 调用的时候 被返回给了 接收的对象
	  --也就是说  想返回给谁 就返回给谁
--}




--练习:
--统计并显示2013-08-09 的oop考试平均分
--如果平均分在70分以上,显示“考试成绩优秀”,并显示前三名学生的考试信息
--如果在以下,显示“考试成绩较差”,并显示后三名学生的考试信息

 select * from result
 order by examdate
 
 --00.求出oop课程对应的课程编号
 declare @subid int 
 select @subid=SubjectId from Subject
 where subjectname='oop'
 
 
 --01.查询平均分
 declare @avg int 
 select @avg=avg(Studentresult) from result
 where examdate>='2013-08-09' and examdate <'2013-08-10'
 and subjectid=@subid
 
 if(@avg>=70)
 begin
   print '成绩优秀'
   -- *打印前三名的成绩
   select  top 3 from result 
   where  examdate>='2013-08-09' and examdate <'2013-08-10'
 and subjectid=@subid
   order by studentresult desc
   
 end
 else
 begin
 print '成绩较差'
 select from Result 
  where  examdate>='2013-08-09' and examdate <'2013-08-10'
 and subjectid=@subid
   order by studentresult 
 end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值