查询计数和求和vb.net [英] query to count and sum vb.net

查看:104
本文介绍了查询计数和求和vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在sql server 2005中有像tis这样的表。现在我想计算第一列中的9s数和第二列中9s的数量。


我不知道在vb.net中有什么查询必须使用??????另外我需要查询总和(column1,column2)???????

任何人都可以帮助我。

column1 column2
9 9
9 7
7 9
9 9

提前感谢。


问候,

Suresh R
(MCA,TCE)

解决方案

要检索您可以在查询下方使用的计数

Dim
scalarCommand As 新SqlCommand " SELECT COUNT(*)FROM table where column1 = 9" ,thisConnection
scalarCommand.ExecuteScalar ())


对于添加部分,是否要在column1中添加完整项目,然后在column2中添加完整项目,或者就像要添加两行(没有用于执行选择的column3)。所以查询。)
喜欢






9 + 9
9 + 7
7 + 9
9 + 9

Hi,

 I am having table like tis in sql server 2005. now i want to count number of 9s in the first column and also number of 9s in the 2nd column.

I dont knw what query have to use for this in vb.net??????  Also i need query to sum(column1, column2)???????

Can anyone help me.

 column1 column2
 9           9
 9           7
 7           9
 9          9

thanks in advance.


Regards, Suresh R (MCA, TCE)

解决方案

To retrieve the count you can use below query  

 
Dim 
scalarCommand As New SqlCommand("SELECT COUNT(*) FROM table where column1 = 9", thisConnection)
   scalarCommand.ExecuteScalar())


For add part do you want to add full items in column1 and then add full items in column2 or is it like you want to add the two rows(there is no column3 for doing the selection. So the query.)
Like
 

    SUM
 9    +     9
 9    +     7
 7    +     9
 9    +     9


这篇关于查询计数和求和vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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