query for finding maximum-th value [Resolved]

Posted by Oswaldlily under Sql Server on 2/28/2013 | Points: 10 | Views : 946 | Status : [Member] | Replies : 3
name year
sony 2000
sony 2500

o/p is maximum th year(2500's) name

desired o/p
name
sony (name of 2500)




Responses

Posted by: Jayakumars on: 2/28/2013 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
hi

vijila

try this Qry

Select item,amt from Table_2 order by amt desc

Mark as Answer if its helpful to you

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sireesha on: 2/28/2013 [Member] Starter | Points: 25

Up
0
Down
select name from tablename where year=(select MAX(year) from tablename)



A.Sireesha

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 2/28/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Try this query

SELECT Name
FROM tablename
WHERE (year IN
(SELECT MAX(year) AS Expr1
FROM tablename AS Table1_1))

This query will give you the exact output.


Thanks & Regards,
Santhi .V

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response