如何逐年计算列名称数量并将其显示在gridview中。 [英] how to count a column name quantity yearwise and display it in gridview.
本文介绍了如何逐年计算列名称数量并将其显示在gridview中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算某个字段的数量(sumtotal)说明数量取决于年份。
假设我有1个表名称facsort并且我有列作为数量,日期,名称等
现在2013年年底,在数据库中插入了多少个数量,我想在gridview中显示它。
i不希望月份插入多少数量。
请帮助。
i将非常有义务。
提前感谢。
解决方案
您可以在查询级别执行此操作本身。只需使用子查询在查询中运行年度总计。
例如选择*,(从表中选择sum(qty),其中数据>'2013/01/01'来自表)
< pre lang =SQL> 选择 count(qnt)来自 facsort group 按 DATEPART(yyyy, date )
how to count(sumtotal)of a certain field say quantity depending on year wise.
suppose i have 1 table name facsort and in that i have columns as qty,date,name etc.
now in 2013 year end, how many qty has been inserted in database, i want to display it in gridview.
i dont want month wise how many qty are inserted.
please kindly help.
i will be highly obliged.
thanks in advance.
解决方案
You can do this at the query level itself. Just run a total for the year within the query by using a subquery.
E.g.select *, (select sum(qty) from table where data > '2013/01/01' from table)
select count(qnt) from facsort group by DATEPART(yyyy, date )
这篇关于如何逐年计算列名称数量并将其显示在gridview中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文