select A.id,A.xmmc,(select count(*) as num from 表A where id<=A.id and A.xmmc = xmmc) as 次数 from 表A A
项目遇到删除:
select OpenId,UserId,(select count(1) from vm_paycustomer tmp where tmp.UserId=tb1.UserId and tmp.OpenId=tb1.OpenId and tmp.PayCustomerId>=tb1.PayCustomerId) as count from vm_paycustomer tb1 ORDER BY tb1.OpenId,tb1.UserId ;