格式化货币以按访问查询分组

时间:2017-05-02 18:56:24

标签: ms-access

我有一张Access表,原始余额为200,000笔贷款,我想把它们分成5,000美元增量,一直到$ 100,000 +,如下:

0-5,000

5,001-10,000

10,001-15,000

(依此类推)

当然,我可以写出世界上最长的IIF声明来满足这些条件,但必须有一个更简单的方法吗?我一直在使用FORMAT()函数来执行与开放日期类似的操作,如下所示:

Month: Format([Loans].[OpenDate],"YYYY-MM") 

有更好的方法吗?

2 个答案:

答案 0 :(得分:2)

将余额除以5000并将其除以此整数部分。

$scope.item.title

答案 1 :(得分:0)

使用范围创建内联视图并加入其中...

我不记得msAccess是否支持select而不使用from或者它是否具有类似oracle的双重....但是必须有一种方式....类似于此......

SELECT A.*, B.Range 
FROM TABLE A
LEFT JOIN (
SELECT 0 as Low, 5000 as High, '0-5000' as Range UNION ALL 
SELECT 5000 as Low, 10000 as High, '5000-10000' as Range UNION ALL 
SELECT 10000 as Low, 15000 as High, '10000-15000' as Range UNION ALL 
SELECT 15000 as Low, 20000 as High, '15000-20000' as Range UNION ALL 
SELECT 20000 as Low, 25000 as High, '20000-25000' as Range UNION ALL 
SELECT 25000 as Low, 30000 as High, '25000-30000' as Range UNION ALL 
SELECT 30000 as Low, 35000 as High, '30000-35000' as Range UNION ALL 
SELECT 35000 as Low, 40000 as High, '35000-40000' as Range UNION ALL 
SELECT 40000 as Low, 45000 as High, '40000-45000' as Range UNION ALL 
SELECT 45000 as Low, 50000 as High, '45000-50000' as Range UNION ALL 
SELECT 50000 as Low, 55000 as High, '50000-55000' as Range UNION ALL 
SELECT 55000 as Low, 60000 as High, '55000-60000' as Range UNION ALL 
SELECT 60000 as Low, 65000 as High, '60000-65000' as Range UNION ALL 
SELECT 65000 as Low, 70000 as High, '65000-70000' as Range UNION ALL 
SELECT 70000 as Low, 75000 as High, '70000-75000' as Range UNION ALL 
SELECT 75000 as Low, 80000 as High, '75000-80000' as Range UNION ALL 
SELECT 80000 as Low, 85000 as High, '80000-85000' as Range UNION ALL 
SELECT 85000 as Low, 90000 as High, '85000-90000' as Range UNION ALL 
SELECT 90000 as Low, 95000 as High, '90000-95000' as Range UNION ALL 
SELECT 95000 as Low, 100000 as High, '95000-100000' as Range 
) B
 on A.Balance > B.Low 
and A.Balance <= B.High