Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ryear	Rexam	Appeared  Passed
2009	MP	100	   80
2010	MP	120	   100
2010	HS	100	   90
2011	MP	120	   90
2011	HS	120	   100
2012    MP      100        100
2012    HS      120        100


above is my table
I want to select two row from the above table where Ryear will be last two year (i.e suppose 2011 and 2012) and Rexam willbe MP.
What is The SQL quary?

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 20-Apr-12 22:12pm
v2

Try this

Select top 2 * from tablename where  Rexam='MP' order by  Ryear desc 
 
Share this answer
 
v2
Comments
P.Salini 21-Apr-12 4:24am    
my 5!
Try:
SQL
SELECT TOP 2 * FROM MyTable WHERE Rexam = 'MP' ORDER BY Ryear DESC
 
Share this answer
 
Comments
P.Salini 21-Apr-12 4:24am    
my 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900