0

I have multiple columns in a table

One column may contain the name of the state (US), another column contains the speciality

Here is some sample data (there could be more than one C# in NY and may also exist in other states)

C# NY
C# NJ
C# WA
C# CA
C# NY
C# NY
Java NY
Java NJ
Java IL

Basically I want to get an output that has

C# 100 (sum of all states that have C#)
Java 85 (sum of all states that have Java)

and I would like to get

State  Total Speciality
NY     150   C# 
NY     100   C++ 

I am using SQLite3 as my DB

1 Answer 1

1

SqlLite should have GROUP BY and COUNT. You may try:

SELECT Speciality, COUNT(State) AS Total
FROM YourTable 
GROUP BY Speciality 

and

SELECT State, Speciality, COUNT(*)  AS Total
FROM YourTable 
GROUP BY State, Speciality 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.