6人合力写出来的T-Sql语句
需求描述:
1.公司有10000人
2.1980年出生的有3000人
3.工资在5000以上的有3000人
4.1980年出生的员工,工资在5000以上的有1000人
查询1980年出生的,工资在5000以上的员工名单
下面是6个同学合力写出来的:
1 --表Employee
2 --出生日期 Birth,类型:datetime
3 --工资 Wage,类型:decimal(18,2)
4 --姓名 EmpName,类型:navarchar(20)
5 --01
6 select EmpName from Employee
7 where Birth = "1980" and Wage = "6000"
8 --02
9 select EmpName from Employee
10 where Birth = "1980" and Wage >5000
11 --03
12 select EmpName from Employee
13 where Birth = '1980' and Wage >5000
14 --04
15 select EmpName from Employee
16 where Birth datetime = '1980' and Wage >50
17 --05
18 select EmpName from Employee
19 where Birth like '1980%' and Wage >5000
20 --06
21 select EmpName from Employee
22 where Birth like '%1980%' and Wage >5000
2 --出生日期 Birth,类型:datetime
3 --工资 Wage,类型:decimal(18,2)
4 --姓名 EmpName,类型:navarchar(20)
5 --01
6 select EmpName from Employee
7 where Birth = "1980" and Wage = "6000"
8 --02
9 select EmpName from Employee
10 where Birth = "1980" and Wage >5000
11 --03
12 select EmpName from Employee
13 where Birth = '1980' and Wage >5000
14 --04
15 select EmpName from Employee
16 where Birth datetime = '1980' and Wage >50
17 --05
18 select EmpName from Employee
19 where Birth like '1980%' and Wage >5000
20 --06
21 select EmpName from Employee
22 where Birth like '%1980%' and Wage >5000
其实我是希望有人写出这样的语句来:
1 select EmpName from Employee
2 where Year(Birth) = 1980 and Wage >5000
2 where Year(Birth) = 1980 and Wage >5000
当然不希望有人写出这样的语句来:
1 select EmpName from Employee
2 where Wage >5000 and Year(Birth) = 1980
2 where Wage >5000 and Year(Birth) = 1980
值得深思!