按月分类&添加列值 [英] sorting by month & adding the column value

查看:81
本文介绍了按月分类&添加列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个c#项目我和visual studio一起工作,我有一个winform,因为有两个组合框,第一个是月份,第二个是年份,旁边是一个按钮。我有一张桌子。在该表中有两列名为date的数据类型为smalldatetime。另一个是价格,当点击按钮时它是varchar我希望根据月份和年份检查表格并显示标签中价格列的总和。那可能吗?我没有使用任何数据网格或任何数据视图这种类型。我正在使用标签显示我可以计算并显示总和吗?

i am doing a c# project i working with visual studio and i have a winform in that there is two combobox the first is of month and second is of year and a button by the side. and i have a table. in that table there is two column named "date" which is having datatype smalldatetime. and another is "price" which is varchar when the button is clicked i want that according to the month and year it checkes the table and display the total sum of the column of price in a label. is that possible to do? i am not using any datagrid or anything dataview such type. i am using a label to display can i calculate and show the sum?

推荐答案

以下查询可能会有所帮助



Following query may help

select sum(price)
from yourtable
where
datepart(mm,yourDateColumn)=yourMonthSelected
and
datepart(yy,yourDateColumn)=yourYearSelected





目前没有SQL访问权限,所以检查语法,虽然逻辑上thsi si correct



希望有所帮助

Milind



Don''t have SQL access at present, so check syntax, though logically thsi si correct

Hope that helps
Milind


这篇关于按月分类&添加列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆