Question Locked

s

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i have table contain 3column(student_id,student_name,department) and multiple row

i need a sql statment
to return the first five student that study english

and i work on windowsapplication in vs 2008 c#

7 replies

by tony hopkinson

select top 5 * From sutudents where department = 'English'

or some such.

If yu wanted the first five alphabetically then add
order by student_name to it, may be

by awadaa

also i need to return the latest two student

by tony hopkinson

write a query that returns the students in the correct order, select the top 2 from it.

by awadaa

i dont understand
i want the last two student
in the same table

by tony hopkinson

worked then instead of just copying it and then asking me the next question in your f'ing homework.

If you have a table called sillytable with one column in it called sillynumber and it has 100 rows containing 1 to a 100 then

select Top 2 from sillytable order by sillynumber

would return records 1 and 2, because 1 1n 2 are the first two records in silly number order

So

select Top 2 from silytable order by sillynumber desc

would return reords 100 and 99 because they are the first two if you sort in descending order.

Most recent student presumably from what you've posted would the two with the biggest ids.

Not being funny but I don't think you are cut out for theis techy stuff. By all means prove me wrong, but you aren't going to do so unless you get your arse in gear.

If you can't figure it out from what I've just posted, give up now.

This discussion is closed to new replies.