Actaully i want max(id ) of each item into one select statement
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='1/2')
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='2/2')
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='2/3')
Mayur DighePosted Feb 17, 2013, 10:25 AM
You can do it..............Just use OR keyword into your SELECT Statement.
e.g.
select item,balance from ACTesting
where id =(select max(id) from ACTesting
where item='1/2' OR item='2/2' OR item='2/3' )
Try....it..., it will Work....
Happy Programming.............
Gurjeet SinghPosted Apr 14, 2013, 3:49 AM
Jignesh TrivediPosted Feb 17, 2013, 10:59 PM
you may also use Union / Union ALL in this case.
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='1/2')
union all
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='2/2')
union all
Select item,balance from ACTesting where id =(select max(id) from ACTesting where item='2/3')
also you may got same out put using mayur suggesion by just replacing "=" with "in"
select item,balance from ACTesting
where id in (select max(id) from ACTesting
where item='1/2' OR item='2/2' OR item='2/3' )
hope this will help you.