Suppose there is a table as below:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
SkillName SkillCode Beginner Proficient Experienced Java 001 2 0 0 Java 001 0 3 0 Java 001 0 0 1
The above table suggests that for the skill Java, there are 2 Beginners, 3 Proficient and 1 Experienced people. I need to write a query which will query the above table and retrieve the results in the form given below, combining the rows:
SkillName SkillCode Beginner Proficient Experienced Java 001 2 3 1
Can you explain me as to how to go about this? An example would be much better. Thanks in advance.
The best example to explain this concept is your own:
SELECT SkillName , SkillCode , SUM(Beginner) AS Beginner , SUM(Proficient) AS Proficient , SUM(Experienced) AS Experienced FROM yourtable GROUP BY SkillName , SkillCode
To understand how this query works, you will need to do some research on two concepts: GROUP BY and aggregate functions, specifically SUM(). Every basic SQL tutorial or textbook will cover these concepts in sufficient detail.
Good luck and welcome to the wonderful world of SQL.
Dig Deeper on Oracle development languages
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.