1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| select \* from Demo
select GETDATE()
select birthady from Demo
select DATEDIFF(yy,'2003-06-01',GETDATE())
select DATEDIFF(yy,birthady,GETDATE()) as '计算结果' from Demo;
select \* from student
select name,age from student where age>30 order by age desc
select name as '姓名' ,age as '年龄' from student where age>30 order by age desc
select top 2 name as '姓名' ,age as '年龄' from student where age>30 order by age desc
select top 2 name as '姓名' ,age as '年龄' , '你好' as '还好' from student where age>30 order by age desc
select top 50 percent name as '姓名' ,age as '年龄' , '你好' as '还好' from student where age>30 order by age desc
select top 50 percent name as '姓名' ,age + 50 as '年龄' , '你好' as '还好' from student where age>30 order by age desc
select \* from student where phone is null or phone = ''
select \* from Student as Stu inner join score as Sco on Stu.Sid = Sco.id
select Stu.name,Sco.name,Sco.age,Sco.sex,Sco.id from Student as Stu inner join score as Sco on Stu.Sid = Sco.id
where Sco.age=20
select \* from score as Sco left join Student as Stu on Stu.Sid = Sco.id
select SUM(age) as '学生年龄和' from Student
select SUM(age) as '学生年龄和' from Student select avg(age) as '学生平均值' from Student select max(age) as '男同学的最大年龄' from score where sex = '男'
select COUNT(\*) as '男同学个数' from score where sex = '男' select max(age) as '男同学的最大年龄' from score where sex = '男'
select count(\*) as '女同学的个数' from score where sex = '女'
select distinct(age) as '男同学的年龄都有那些' from score where sex = '男'
select sex,COUNT(\*) as '个数' from score group by sex
select sex,COUNT(\*) as '个数' from score where age > 1 group by sex having COUNT(\*) < 1
select \* from Usersinfo where LoginName in ('lilei@163.com')
select Note.Title,Note.Content,Usr.UserName from Usersinfo as Usr inner join NoteInfo as Note on Usr.UserId = Note.NoteId where Usr.LoginName = 'lilei@163.com'
select CategoryName,COUNT(\*) as '个数' from NoteCategory group by CategoryName
select \* from Usersinfo where LoginName like '%lilei.163.com%'
use school select \* from student;
insert into student values(2,3,4,5,6,7);
insert into student (name,sex,age) values (4,5,6)
insert into student values (4,5,6,7,8), (5,6,7,8,9) insert into Patient (password,BirthDate,Gender,PatientName,PhoneNum,Email,IndentityNum,Address) values(123456,'1985-06-07','女','夏颖',13800000001,'ying.xia@qq.com',110000198506071100,'厦门市'), (234567,'1985-06-08','男','李政',1380000002,'lizheng@163.com',210000198506082100,'长春市') select \* from Patient;
UPDATE Patient set Password='11111'
delete from Patient where Patient=1;
delete from Patient
select distinct sex from Student
|