我在表中有多列
一列可能包含州名(US),另一列包含专业
以下是一些示例数据(纽约可能有多个C#,也可能存在于其他州)
C# NY
C# NJ
C# WA
C# CA
C# NY
C# NY
Java NY
Java NJ
Java IL
基本上我想得到一个
的输出C# 100 (sum of all states that have C#)
Java 85 (sum of all states that have Java)
我想得到
State Total Speciality
NY 150 C#
NY 100 C++
我使用SQLite3作为我的数据库
答案 0 :(得分:1)
Sqlite应该有GROUP BY和COUNT。你可以尝试:
SELECT Speciality, COUNT(State) AS Total
FROM YourTable
GROUP BY Speciality
和
SELECT State, Speciality, COUNT(*) AS Total
FROM YourTable
GROUP BY State, Speciality