选择distinct和sum [英] Select distinct and sum

查看:384
本文介绍了选择distinct和sum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所以我遇到了一个问题需要这么基本上我在msaccess中有这个数据库,我正在尝试编码vb



代理商|销售

------------

shaun | 4

shaun | 5

丽莎| 1

lisa | 5





我需要它做的是收集代理商名称一次并计算销售额,例如



代理商|销售

------------

shaun | 8

丽莎| 6



任何帮助都会很棒,谢谢



我尝试了什么:



SELECT DISTINCT(代理商),SUM(销售)来自销售

解决方案

不,你需要一个GROUP BY:

  SELECT 代理商,SUM(销售) FROM 销售 GROUP   BY 代理商


感谢磨坊我能爱你:D


Hi so i got a problem that requires so basically i have this database in msaccess that i'm trying to code in vb

agents|sales
------------
shaun | 4
shaun | 5
lisa | 1
lisa | 5


what i need it to do is to collect the agents name once and calculate the sales so for e.g

agents|sales
------------
shaun | 8
lisa | 6

any help would be great thanks

What I have tried:

"SELECT DISTINCT(agent), SUM(sales) FROM SALES"

解决方案

No, you need a GROUP BY:

SELECT Agents, SUM(Sales) FROM Sales GROUP BY Agents


thanks a mill i could love u :D


这篇关于选择distinct和sum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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