Ticket #29: x.txt

File x.txt, 1.6 KB (added by chenchongqi, 15 years ago)
Line 
1select count(id) from
2 (  select id,user_id,star,commend,last_update_date from (select row_number()
3  over (partition by n.user_id order by n.last_update_date desc) as tp,n.id
4  as id, n.last_update_date as last_update_date,n.user_id as user_id, c.star,
5  decode(t3.company_id, null, 0, 1) as commend from ent_news n,ent_company c ,
6   (select company_id from pdl_ad where company_id>0 and brand_id=:1 union
7  select company_id from pp_ad where company_id>0 and brand_id=:2) t3  where
8  n.status<=1 and  n.valid_end_date>=sysdate and n.user_id=c.id(+)  and
9  c.status>=0 and  c.vip_rank = 3 and c.star = 2 and c.id = t3.company_id(+)
10  and n.product_id is not null  and concat(n.province, n.city) like '%¹ãÖÝ%'
11  and  n.news_type in(4,5,1) and n.brand_id=23839 ) where tp=1  and rownum <=
12  2  union all   select id,user_id,star,commend,last_update_date from (select
13  row_number() over (partition by n.user_id order by n.last_update_date desc)
14  as tp,n.id as id, n.last_update_date as last_update_date,n.user_id as
15  user_id, c.star,decode(t3.company_id, null, 0, 1) as commend from ent_news
16  n,ent_company c , (select company_id from pdl_ad where company_id>0 and
17  brand_id=:3 union select company_id from pp_ad where company_id>0 and
18  brand_id=:4) t3  where n.status<=1 and n.valid_end_date>=sysdate and
19  n.user_id=c.id(+)  and c.status>=0 and  c.vip_rank = 3 and c.star<>2 and
20  c.id = t3.company_id(+)  and n.product_id is not null  and
21  concat(n.province, n.city) like '%¹ãÖÝ%'  and  n.news_type in(4,5,1) and
22  n.brand_id=23839 ) where tp=1 order by star desc,commend desc,
23  last_update_date desc)
24
25