有谁知道创建此结果的轴的简单方法:
[0-1] [1-2] [2-3] [3-4]
12 45 29 5
此结果是使用查询创建的:
SELECT [0-1] = SUM(CASE WHEN AGE >= 0 AND AGE <= 1 THEN 1 ELSE 0 END),
[1-2] = SUM(CASE WHEN AGE > 1 AND AGE <= 2 THEN 1 ELSE 0 END),
[2-3] = SUM(CASE WHEN AGE > 2 AND AGE <= 3 THEN 1 ELSE 0 END)
FROM dbo.Persons
我想将列值显示为行,即输出应如下所示:
[0-1] 12
[1-2] 45
[2-3] 29
[3-4] 5
也欢迎链接到文章/博客。请提出一个简单易懂的解决方案。