日期:2014-05-17 浏览次数:20543 次
;with cte as
(
select C_AreaCode,c_producename,count(1) ct
from Consumer_Airconditioning_12Y10M
where C_AreaCode like '1101__'
group by C_AreaCode,c_producename
)
select * from cte,
(
select *,row_number() over(partition by C_AreaCode,C_ProduceName order by C_ID desc)rn1
from Consumer_Airconditioning_12Y10M where c_id in
(select min(c_id) from Consumer_Airconditioning_12Y10M where C_AreaCode like '1101__' group by C_Name,C_Tel)
) t1
where t1.C_AreaCode=cte.C_AreaCode and t1.c_producename=cte.c_producename
and rn1<=ct/10
order by C_AreaCode,C_ProduceName,rn1