如题:table表字段:serialno,username,cellphone,accountid,groupid
根据groupid分组查询,我想得到每组的cellphone(手机号)数据,我sql这样写
“select count(cellphone) from mdao_member where accountid = ? group by groupid”得到是每组的手机个数,
可是我想得到cellphone的具体数据该怎么做?
根据groupid分组查询,我想得到每组的cellphone(手机号)数据,我sql这样写
“select count(cellphone) from mdao_member where accountid = ? group by groupid”得到是每组的手机个数,
可是我想得到cellphone的具体数据该怎么做?
from tb
order by groupid
select a.groupid,STUFF((select ';'+cellphone from mdao_member where groupid=a.groupid for xml path('')),1,1,'') as cellphone
from mdao_member as a where a.accountid = ? group by a.groupid