how to select rows with sum of group in sqlite3?
Let say I have data in sqlite3 like this:
|saleID|data|
|1|a|
|1|b|
|1|c|
|2|x|
|2开发者_如何学C|y|
|3|t|
|4|x|
|4|y|
I want to count how many times saleID in table appear. How the sql syntax in sqlite to get result like this?
|saleID|count|
|1|3|
|2|2|
|3|1|
|4|2|
Thanks for coder..
select saleID, count(1) as [count]
from sales
group by saleID
you just need to use group by:
select saleID,COUNT(data) from Table group by salesID
Regards
SELECT saleID, COUNT(*) FROM YourTable GROUP BY saleID
精彩评论