表结构和数据如下:
ID type count
1 a 10
2 b 20
3 c 30
4 d 5
5 b 13
6 c 2
7 b 7
请问如果SQL语句按"type"求出count总数ID type count
1 a 10
2 b 40
3 c 32
4 d 5
多谢!
ID type count
1 a 10
2 b 20
3 c 30
4 d 5
5 b 13
6 c 2
7 b 7
请问如果SQL语句按"type"求出count总数ID type count
1 a 10
2 b 40
3 c 32
4 d 5
多谢!
from 表
group by type
order by type
select * from #temp
/////////////////////
使用完后要
drop table #temp
select Type, Sum(Count) as perCount from table1 group by Type order by Type
add an order func...
取:ADOQuery.FieldByName('perCount').asString is OK
select min(id) as id, Type, Sum(Count) as count from table1 group by Type
2:
select identity(int,1,1) as id,* into #tmp
from
(
select Type,Sum(Count) from table1 group by Type
) aa
select * from #tmp
drop table #tmp
select min(id), Type, Sum(Count) from table1 group by Type********************************
这个最可取