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 = "1980and Wage = "6000"
 8 --02
 9 select EmpName from Employee
10  where Birth = "1980and 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

 

当然不希望有人写出这样的语句来:

 

1 select EmpName from Employee
2  where Wage >5000 and Year(Birth) = 1980

 

值得深思!

 

posted on   Ferry  阅读(3957)  评论(51编辑  收藏  举报

编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
< 2009年11月 >
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 1 2 3 4 5
6 7 8 9 10 11 12

导航

统计

点击右上角即可分享
微信分享提示