有表结构如下:
table1
id name shiyong1 shiyong2
1 aaa yes no
2 bbb yse yse
3 bbb yes no
............怎么写sql能查出如下的效果?
name shiyong1num shiyong2num
aaa 1 0
bbb 2 1
table1
id name shiyong1 shiyong2
1 aaa yes no
2 bbb yse yse
3 bbb yes no
............怎么写sql能查出如下的效果?
name shiyong1num shiyong2num
aaa 1 0
bbb 2 1
你这样可以做个视图就可以了,不用SQL查吧。
更改名字用AS
select name,count(shiyong1) as shiyong1num,count(shiyong2) as shiyong2num from table1
group by name
from table
group by name
同意yingkiller(大飞虫) ( )
等会得分多
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=170924
帖子参见
http://expert.csdn.net/Expert/topic/1895/1895274.xml?temp=.881344