(select table5.shopareaid,table5.usersid ,table5.username  from   (select sg.shopareaid,u1.usersid,u1.username,row_number() OVER(PARTITION BY sg.shopareaid ORDER BY sg.shopareaid desc) numbers from shops s, shopgroup sg,users u1 where s.shopgroupid = sg.shopgroupid and   u1.companysid=7 and u1.usertitle = 40 and u1.status<=2 and s.shopsid=u1.residentshopid) table5 where table5.numbers=1) table1,

 

.

posted on 2017-05-31 17:10  烟波竹客  阅读(599)  评论(0编辑  收藏  举报