如何出需求的sql?
table a
id name groupid state type type2
1 model1 1 1 a A
2 model2 1 1 a A
3 model3 1 1 a B
4 model4 1 0 a B
5 model5 2 1 b A
6 model6 2 0 b A
7 model7 2 0 b B
8 model8 2 1 b B
9 model9 2 1 b B
需要示根groupid,和state=1做件的果:
type count
a 3
b 3
的sql如何?
各位啦!!
[解决办法]
select type ,count(1) as [count]
from a
where state =1
group by type
[解决办法]
select type,count(type) from a where state=1 group by a order by groupid
[解决办法]
select type,count=count(*) from a
where state =1
group by type
[解决办法]
(@_@)!