条件查询-1
select * from People
--查询性别为女的员工信息
select * from People where PeopleSex = '女'
--查询工资大于等于10000元的员工信息
select * from People where PeopleSalary>=10000
--查询出性别为女 工资大于10000元的员工信息 多条件
select * from People where PeopleSex = '女' and PeopleSalary>=10000
--查询月薪大于等于10000员工,或者月薪大于等于8000的女员工
select* from People where PeopleSalary>=10000 or
(PeopleSalary>=8000 and PeopleSex='女')
--查询月薪大于等于15000员工 或者月薪大于等于8000女员工
selectfrom People where PeopleSalary>=15000 or
(PeopleSalary >=8000 and PeopleSex='女')
--查询出出生年月在1980-1-1之后,而且月薪大于等于10000的女员工
select from People where PeopleBirth>='1980-1-1' and
(PeopleSalary>=10000 and PeopleSex='女')
--查询月薪在10000-20000之间的员工信息(多条件)
select* from People where PeopleSalary>=10000 and PeopleSalary<=20000
select* from People where PeopleSalary between 10000 and 20000
--查询出地址在武汉或者北京的员工信息
select* from People where PeopleAddress = '武汉'or PeopleAddress = '北京'
select* from People where PeopleAddress in('武汉','北京')
--排序 查询所有员工信息 根据工资排序 降序 asc升序 desc降序
select* from People order by PeopleSalary asc
--查询所有员工信息 根据名字长度排序 降序
select* from People order by len(PeopleName) desc
--查询出工资最高的5个人的信息
select top 5* from People order by PeopleSalary desc
--查询出工资最高的10%的员工信息
select top 10 percent * from People order by PeopleSalary desc
--null 空值
insert into People(DepartmentId,RankId,PeopleName,PeopleSex,PeopleBirth,
PeopleSalary,PeoplePhone,PeopleAddress,PeopleAddTime)
values(1,1,'命运','男','1977-7-7',500000,'13864378825','',GETDATE())
--查询出地址没有填写的员工信息
select* from People where PeopleAddress is null
--查询出地址已经填写的员工信息
select * from People where PeopleAddress is not null

浙公网安备 33010602011771号