如何计算范围内一列的值。 [英] How to count values from one column within a range.
本文介绍了如何计算范围内一列的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为Displacement的表,其中有一个包含置换日期的列。我想要下面提到的列的日期计数。什么应该是这种情况的查询。
2007年之前,2007-2008之间,2008-2009之间,
我尝试了以下查询,但它无效。
I have a table named as Displacement, in which there is a column containg date of displacement. I want the count of dates for the columns mentionted below. What should be the query for such condition.
Before 2007, Between 2007-2008, Between 2008-2009,
I have tried the following query but its not working.
Select
SUM(CASE isnull(Year(IO7_DateOfDisplacement), 0) WHEN (IO7_DateOfDisplacement is < 2007) THEN 1 ELSE 0 END) AS [Before 2007],
SUM(CASE isnull(Year(IO7_DateOfDisplacement), 0) WHEN (Between 2007 and 2008) THEN 1 ELSE 0 END) AS [Between 2007-2008]
我将感谢您的帮助。
Usama Javed
I shall be thankful for you help.
Usama Javed
推荐答案
select SUM(xyz) from table_name where YEAR(your date field)=//or whatever is your condition
问候......:笑:
Regards..:laugh:
这篇关于如何计算范围内一列的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文