How to sum column based on distinct values from another?
Go to Solution. 06-02-2020 03:46 AM You may need to create calculated columns as below: The result will show as below: You also can try to create measure like this: Here is a sample. If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Why does MySQL-sum ( distinct ) not work?
SUM (DISTINCT last_name, first_name) would not work, of course, because I’m trying to sum the rate column, not the names. I know when counting individual records, I can use COUNT (DISTINCT last_name, first_name), and that is the type of behavior I am trying to get from SUM.
When do you need a sum of all table?
If you want to get all sum of those little ” sums “, you will get a sum of all table.. but, if for some reason are differents (if you use a where, for example) and you need a sum for that select above, just do. Gonzalo.-
How to do group by hidden columns in MySQL?
You can use any of the above code sample provided since with group by clause without any aggregate function will return an indeterminate one record for each grouping condition. You can refer http://dev.mysql.com/doc/refman/5.5/en/group-by-hidden-columns.html link for further reading.
Why is MySQL-distinct based on other columns not working?
I need the SUM of those rows to be 8, not 24, so it counts the rate once for each group of names. SUM (DISTINCT last_name, first_name) would not work, of course, because I’m trying to sum the rate column, not the names.
How to sum column based on values in another column?
Let’s take it one step at a time, and start by writing a formula in C7 that adds up the sales column, but only includes products with a rating equal to 9. This isn’t exactly what we want (we really want greater than 9, not equal to 9), but it will help us get the basic arguments into the function.
How to sum the weight column only once?
The formula to sum the weight column is obvious… and results in 2. Now I would like to ad a filter to that formula to sum the weight values only once for each unique value in the id row (which would result in 1). Any ideas? Ricardo is correct, the sumx approach will not work if any of the id’s have the same weight.