我有一张桌子Orders
Name             DateOrdered
louie            01/50/2017
jonathan         02/06/2016
prince           05/23/2016
louie            07/02/2016我想按年份选择记录,例如2016年,但我希望结果只显示jonathan和prince,因为louie有2017年的最新记录,如何查询?提前谢谢。
发布于 2017-10-10 10:36:19
With子查询。例如,在transact sql ( sybase ase)中
Select from orders a
Where DateOrdered  != (select min(dateordered) from orders b 
                       where convert(char(04),dateordered)=convert(char(04),a.dateordered))convert函数用于比较字段dateordered中的年份部分
我希望它能对你有所帮助。
https://stackoverflow.com/questions/46657690
复制相似问题