我有一张这样的表
Days taken
12
10
10
12
9
10
8
10
我想要一个像这样放置的查询
Type | Count
Days over 10 | 2
Days under 10 | 6
我到目前为止
SELECT Sum(IIf([table].[days taken]<=10,1,0)) AS [Days Under Ten],
Sum(IIf([table].[days taken]>10,1,0)) AS [Days Over Ten]
FROM [table];
这给了我这个
Days under ten | Days over ten
6 | 2
但它不是我想要的,请帮助我。
答案 0 :(得分:2)
您当前的查询非常接近正确的版本。您将需要使用:
SELECT
IIF([days taken] <=10, 'Days under 10', 'Days over 10') as Type,
count([days taken]) as Total
FROM yourtable
group by IIF([days taken] <=10, 'Days under 10', 'Days over 10')
您会看到我使用IIF
分配Days over 10
或Days under 10
。然后,您将相同的IIF
添加到GROUP BY
以获取count()