MySQL Adding columns together

HiiSpeedLOWdrag

Quick MySQL problem.

I'm wanting to add multiple columns (column 2) together based one column (column 1) being checked to ensure they hold matching values

Example

Column 1

Team 1     
Team 2      
Team 3       
Team 1    
Team 3   
Team 2  

Column 2

 1
 2
 3 
 1
 2
 3

Column 3 (Calculated based on the Values in Column 1 matching)

 2 (Team 1)
 4 (Team 2)
 6 (Team 3)

Of course I will begin by doing the following select statement:

SELECT Column 1, Column 2 FROM table WHERE ???

After the where is when I don't know what comes next to add the columns together based on the first column holding the same value.

dcp

Looks to me like you just need a simple sum and group by. But I think in your example, Team 2 should have a total of 5, not 4.

SELECT column1,sum(column2) FROM table
group by column1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL Adding columns together

From Dev

Adding all columns together?

From Dev

SQL adding columns together

From Dev

Adding two time columns together in pandas dataframe?

From Dev

Adding two time columns together in pandas dataframe?

From Dev

subracting two columns after firstly adding two columns together

From Dev

mysql-problems with adding columns

From Dev

Adding two columns together in CSV and outputting to new CSV file

From Dev

Adding together 4 different Tablix data columns SSRS

From Java

Adding multiple columns AFTER a specific column in MySQL

From Dev

MySQL - Sort multiple columns together; not first, then second, etc

From Dev

Adding together timedeltas in Python

From Dev

Adding strings in lists together

From Dev

Adding together values of ENUMs

From Dev

Adding label text together

From Dev

Adding Android views together

From Dev

adding parts of a javabean together

From Dev

Adding strings together in CUDA?

From Dev

Adding together calculated variables

From Dev

Datatables - Merge columns together

From Dev

Pasting together subsetted columns

From Dev

MySQL, Adding two columns recursively after comparing them

From Dev

adding different columns in same table usin inner join in mysql

From Dev

Adding two strings together in python

From Dev

Adding two DateTime objects together

From Dev

Adding values of radio buttons together

From Dev

Adding components of a list together for BlackJack

From Dev

Adding together labels in Assembly Language?

From Dev

Adding together matrices in C++