Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in writting a query

Status
Not open for further replies.

nnmmss

Programmer
Sep 7, 2004
123
0
0
IR
suppose i have a tbale with these data on it

PrfNo PrfVer Quantity_Total PrjId SupplierId GoodsId
Ab_43 1 34 15 20 29
Ab_44 1 31 15 20 29
Ab_44 2 30 15 20 29
Ab_43 2 12 15 20 29
Ab_43 3 4 15 20 29

i want to have query which gives me the record with maximum PrfVer for for every PrfNo , it means i want to have this result
PrfNo PrfVer Quantity_Total PrjId SupplierId GoodsId
Ab_44 2 30 15 20 29
Ab_43 3 4 15 20 29

i couldn't write any query for that, is there anybody help me to writting this query?
 
Code:
select PrfNo
     , PrfVer
     , Quantity_Total
     , PrjId
     , SupplierId
     , GoodsId
  from daTable as T
 where PrfVer
     = ( select max(PrfVer)
           from daTable
          where PrfNo = T.PrfNo )

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top