Google SQL Pivot make 0 显示 NULL
我有一个数据透视表,只要数据库中没有值,我就需要返回 NULL。当您查看 Google API 的查询语言时,这似乎非常简单: http://code.google.com/apis/visualization/documentation/ querylanguage.html#Pivot
(来源:cjweed.com)
(来源:descentcampaign.com)
Google 示例为第一个图像。注意它如何包含 null,这些 null 值来自原始表中不存在的数据。当我运行 sum(vals) 以使枢轴工作时,它总是返回 0,即使它不存在。
另外,我的sql语句是:
<代码> SELECT weekNumber, sum(value) FROM allval
其中 weekNumber != 0 AND custId != 28
按周数分组
PIVOT custId
按周数排序
注意 custId != 28。它仍然出现在我的结果表中,只是所有内容都设置为 0。
任何人都知道链接中的 Google 示例如何能够通过聚合函数 sum 来维护 NULL 值?
I have a pivot table that I need to have return NULL whenever there is not a value in the database. This seems pretty simple when you look at the Google API for their query language:
http://code.google.com/apis/visualization/documentation/querylanguage.html#Pivot
(source: cjweed.com)
(source: descentcampaign.com)
The Google example is the first image. Notice how it contains null, these null values are from data that does not exist in the original table. When I run the sum(vals) for the pivot to work, it always returns 0, even if it doesn't exist.
Also, my sql statement is:
SELECT weekNumber, sum(value) FROM allval
WHERE weekNumber != 0 AND custId != 28
GROUP BY weekNumber
PIVOT custId
ORDER BY weekNumber
Notice the custId != 28. It still appears in my result table, except everything is set to 0.
Anyone know how the Google example in the link was able to maintain the NULL values even through the aggregate function sum?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论