简体   繁体   English

VB.NET/Access - SELECT SUM SQL 语句

[英]VB.NET/Access - SELECT SUM SQL statement

I have a table with LastName, FirstName, Wins, Losses, CompFormat and Medals columns.我有一个包含姓氏、名字、胜利、损失、CompFormat 和奖牌列的表。 In case the person who told me not to use pictures on my last question sees this I tried your suggestion and couldn't figure it out so I have to use pictures.如果在我的最后一个问题中告诉我不要使用图片的人看到了这一点,我尝试了您的建议但无法弄清楚,所以我必须使用图片。 So don't bite my head off this time.所以这次不要咬我的头。 I successfully added and grouped Wins with CompFormat like this...我像这样成功地使用 CompFormat 添加和分组了 Wins ...

("SELECT SUM(Wins) AS Total, FirstName, LastName, CompFormat FROM CompetitionDate GROUP BY LastName, FirstName, CompFormat;")

Which correctly produced this in my datagridview...在我的 datagridview 中正确地产生了这个......

正确的结果

Instead of what I did I want to add counting losses and group it to look like this我想添加计数损失并将其分组为这样,而不是我所做的

在此处输入图片说明

Here is my access table...这是我的访问表...

在此处输入图片说明

I think you just need to add the Losses column:我认为您只需要添加Losses列:

SELECT FirstName, LastName, CompFormat,
       SUM(Wins) AS Wins, SUM(Losses) as Losses
FROM CompetitionDate
GROUP BY LastName, FirstName, CompFormat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM