我有以下查询(运行良好),可以提取ID,周结束日期,效果和加班费。
SELECT
d2s_roster_tbl.employee_id,
Format([WEEK_ENDING_DT],"mm/dd") AS week,
IIf([d2s_performance_tbl].[hrs_worked]=0,"",IIf([d2s_roster_tbl.position_desc] Like
"*selector*",FormatPercent(Round(([d2s_performance_tbl].[goal_hrs]/[d2s_performance_tbl].[hrs_worked]),2),0) &
[d2s_performance_tbl].[lift_flag],IIf([d2s_roster_tbl.position_desc] Like
"*operator*",FormatPercent(Round(([d2s_performance_tbl].[goal_hrs]/[d2s_performance_tbl].[hrs_worked]),2),0),""))) AS Perf,
d2s_performance_tbl.OT
FROM
d2s_roster_tbl
INNER JOIN d2s_performance_tbl ON D2s_roster_tbl.employee_id = d2s_performance_tbl.employee_id;
当我按OT排序时,它排序正确。当我按perf(计算的百分比)排序时,它似乎只按第一个数字排序 - 降序排序显示如下结果:
6%
52%
500%
475%
47%
4%
39%
30%
23%
220%
199%
19%
188%
是什么导致它像这样排序? d2s_performance_tbl中的所有数字字段都有2个小数位,格式如下:
Field Size: Double
Format: General Number
Decimal Places: Auto
谢谢!
答案 0 :(得分:2)
我认为这是由FormatPercent
函数引起的,根据我的理解,它只能是逻辑的,它转换为字符串。在值中只有'%'的唯一方法是它是否为字符串。这就是导致你失败的原因。移除FormatPercent
,看看会发生什么。
如果您想要格式化的值,您可以在输出中添加另一列作为格式,并对未计算的格式进行排序,以便按正确顺序获取格式化的列。