Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL QUERY

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-07 : 12:10:42
Vicky writes "I need to know how would you write this simple query as I am a beginner in learning SQL

There is a table with one column for Student names and than the other for Student rank.

We need to find the top 3 ranks.

The order of ranks is 1,2,3,3(Because two people rank exactly the same). So the output would have to include them both.

Please help me out.

I need to find the output that has first 3 ranks but there are four people because the two people have the same rank and score.

Thanks"

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-06-07 : 12:17:27
Select Studentname,Studentrank
From Table1
Where Studentrank = '1' Or Studentrank = '2' Or Studentrank = '3'
Orderby Studentrank
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-06-07 : 12:17:31
What's the name of the course?

Look up DISTINCT and TOP



Brett

8-)
Go to Top of Page
   

- Advertisement -