select count(id) from ( select id,user_id,star,commend,last_update_date from (select row_number() over (partition by n.user_id order by n.last_update_date desc) as tp,n.id as id, n.last_update_date as last_update_date,n.user_id as user_id, c.star, decode(t3.company_id, null, 0, 1) as commend from ent_news n,ent_company c , (select company_id from pdl_ad where company_id>0 and brand_id=:1 union select company_id from pp_ad where company_id>0 and brand_id=:2) t3 where n.status<=1 and n.valid_end_date>=sysdate and n.user_id=c.id(+) and c.status>=0 and c.vip_rank = 3 and c.star = 2 and c.id = t3.company_id(+) and n.product_id is not null and concat(n.province, n.city) like '%¹ãÖÝ%' and n.news_type in(4,5,1) and n.brand_id=23839 ) where tp=1 and rownum <= 2 union all select id,user_id,star,commend,last_update_date from (select row_number() over (partition by n.user_id order by n.last_update_date desc) as tp,n.id as id, n.last_update_date as last_update_date,n.user_id as user_id, c.star,decode(t3.company_id, null, 0, 1) as commend from ent_news n,ent_company c , (select company_id from pdl_ad where company_id>0 and brand_id=:3 union select company_id from pp_ad where company_id>0 and brand_id=:4) t3 where n.status<=1 and n.valid_end_date>=sysdate and n.user_id=c.id(+) and c.status>=0 and c.vip_rank = 3 and c.star<>2 and c.id = t3.company_id(+) and n.product_id is not null and concat(n.province, n.city) like '%¹ãÖÝ%' and n.news_type in(4,5,1) and n.brand_id=23839 ) where tp=1 order by star desc,commend desc, last_update_date desc)