以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 查询表的重复值问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157865) |
-- 作者:nbsugu_z -- 发布时间:2020/10/31 11:33:00 -- 查询表的重复值问题 S e lect Id As [序号],MachNo As [机器号],CardNO As [内部卡号],CardType As [车类型],InTime As [进场时间],OutTime As [出场时间],FreeType As [优惠类型],FreeNumber As [优惠金额],CreateTime As [扫码时间],IsAccount As [收费金额],AccountDate As [建库时间],CarNo As [车牌号],CustomerID As [商家代码],DisCountID As [记录流水号],TicketNo As [优惠券号] From {FreeLog} Where customerID=\'00059\' Order By createtime 老师以上代码想增加一个条件:排除上面红色字段重复的值,就是只取一条。如何加条件
|
-- 作者:有点蓝 -- 发布时间:2020/10/31 11:47:00 -- select Id As [序号],MachNo As [机器号],CardNO As [内部卡号],CardType As [车类型],InTime As [进场时间],OutTime As [出场时间],FreeType As [优惠类型],FreeNumber As [优惠金额],CreateTime As [扫码时间],IsAccount As [收费金额],AccountDate As [建库时间],CarNo As [车牌号],CustomerID As [商家代码],DisCountID As [记录流水号],b.TicketNo As [优惠券号] from (select TicketNo ,max([_Identify]) as dd from {FreeLog} Where customerID=\'00059\' Order By createtime) as a inner join {FreeLog} as b on a.[_Identify]=b.[_Identify] Where b.customerID=\'00059\' Order By b.createtime
|
-- 作者:nbsugu_z -- 发布时间:2020/10/31 11:58:00 -- 除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。 |
-- 作者:有点蓝 -- 发布时间:2020/10/31 13:57:00 -- 去掉中间的Order By createtime |
-- 作者:nbsugu_z -- 发布时间:2020/11/2 13:18:00 -- .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.5.18.8 错误所在事件: 详细错误信息: 列名 \'_Identify\' 无效。 列名 \'_Identify\' 无效。 列名 \'_Identify\' 无效。 |
-- 作者:有点蓝 -- 发布时间:2020/11/2 13:53:00 -- 改为自己表格的主键 |