I have a table with 4 columns: Client , thickness , material and amount.

I want to make a SQL select-query to select everything, but when the client, thickness and material are the same their value of 'amount' should be added.

How would I go about creating such a query?


1 Answer 1


This is straightforward (a simple GROUP BY):

SELECT Client, thickness, material, SUM(amount) as amount
FROM your_table
GROUP BY Client, thickness, material;

Change your_table for the name of your table. If only 1 row exists of one combination of Client, thickness and material, it will select it as is.

Check the GROUP BY MySQL page for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.