--储存 字符串 类型
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
第三章 SQL编程 课上知识点笔记
最新推荐文章于 2024-01-24 13:47:50 发布