sql分组查询统计次数问题
如图,当Compound和Block字段都和下一条数据的Compound和Block字段相等的时候,统计为一条数据,并增加一列,是多少条数据相等,这个SQL如何写?
例如:
则得出列表:Compound Block times
304T_1 TE00108B 3
[解决办法]
select Compound, Block, count(1) as times from tblName group by Compound, Block