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

来源:互联网 发布:网络浙江卫视在线直播 编辑:程序博客网 时间:2024/05/23 02:07
--储存 字符串 类型declare @name nvarchar(32)set @name ='小雨吧'print @name--储存 浮点型 declare @Blance decimal(18,7)set @Blance=12.36print @Blance--储存 字符串型 declare @Brithday datetimeset @Brithday='1998-3-30'print @Brithday--最后一个T-SQL语句的 错误符号select @@ERROR --输出 计算机的名称select @@SERVERNAME--输出 自增列 最后一次插入的标示值select @@IDENTITY--cast  convert  转换declare @num int set @num=5print '值是:'+cast(@num as nvarchar(32))declare @numm int set @numm=6print '值是:'+convert(nvarchar(32),@numm)--if-elese 结构declare @age intset @age=30  if(@age=30)begin    print'库里'end  elsebegin    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
原创粉丝点击