Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Group row by specified value

I have data like this :

Name Value
German 4
French 1
FrenchSecond 1
English 2

With SQL, I want to merge manually (French and FrenchSecond) and sum the "Value" :

Name Value
German 4
French 2
English 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You may use a CASE expression for this purpose:

SELECT CASE WHEN Name LIKE 'French%' THEN 'French' ELSE Name END AS Name,
       SUM(Value) AS Value
FROM yourTable
GROUP BY CASE WHEN Name LIKE 'French%' THEN 'French' ELSE Name END;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading