-- 2005
select * from
 (
  select A.*,B.ANAME,B.Address,row_number() over(partition by B.BID order by A.AID) rownum
  from A,B where A.BID = B.BID
 )T
where rownum <=4
order by A.AID