本文介绍了跨月字段比较 2 个表之间的值 SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
当前演示:
命令表表达式返回是否曾订购过任何项目.然后,我们只需要计算/求和:
Current demo: http://sqlfiddle.com/#!18/7acdc/17
I am looking for a total of how many items were added in a specific month but then a total of how many were never ordered after that.
Tables:
Currently i have:
Which produces:
But i am looking for a result set such as:
I am struggling to get this working. Do i need a sub-query or something to match the items individually. Can anyone push me in the right direction? Thanks
解决方案
Maybe this:
The Commant Table Expression returns if any item was ever ordered. Then, we just need to count/sum:
这篇关于跨月字段比较 2 个表之间的值 SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!