On Thu, 2004-04-08 at 11:15, Saqib Qureshi wrote: > but actually i want to fatch each year record in a separate variable and in > a single query how it is possible.
Hi, try this : select a2.zon, b2.astyer, count(a2.ntn), b3.astyer, count(a3.ntn) from ztrmtrext a2, rtnmtr b2, ztrmtrext a3, rtnmtr b3 where a2.ntn = b2.ntn and b2.astdat is null and b2.astyer='2002' and a3.ntn = b3.ntn and b3.astdat is null and b3.astyer='2003' and a2.zon = a3.zon group by a2.zon, b2.astyer, b3.astyer ; Please note, that you will only get lines listet that have the "zon"-Values in any year asked for. You will have to use "outer joins" if not all "zon"-Values are in any year. For details on what an "outer join" is, you can look at http://www.1keydata.com/sql/sqlouterjoin.html or http://www.adp-gmbh.ch/ora/sql/outer_join.html . Wilfried Essig -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]