如何在Sql Vb.Net中计算唯一行数 [英] How Do I Count Unique Rows In Sql Vb.Net

查看:100
本文介绍了如何在Sql Vb.Net中计算唯一行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有以下内容的sql datbase:



产品:金额:

PCB1 2

PCB1 6

PCB2 54

PCB2 23



我有兴趣计算相同产品的数量并显示它在数据网格视图中。



刚刚在sql命令之后和下面的代码填充datagridview。



如果有人可以提供帮助,那就太棒了。



非常感谢,

Pete:)

I have a sql datbase with the following:

Product: Amount:
PCB1 2
PCB1 6
PCB2 54
PCB2 23

im interested in counting the amount of the same product and displaying it in a datagrid view.

just after the sql command and following code to populate the datagridview.

If anyone could help, that would be great.

Many Thanks,
Pete :)

推荐答案

试试这个



try this

select Product,Sum(Amount) as [Amount] from tbl
group by product 


这篇关于如何在Sql Vb.Net中计算唯一行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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