Question

Locked

s

By awadaa ·
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#

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

depends on what you mean by first...

by Tony Hopkinson In reply to s

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

Collapse -

ok

by awadaa In reply to depends on what you mean ...

thank u very much
it is right

Collapse -

the

by awadaa In reply to depends on what you mean ...

also i need to return the latest two student

Collapse -

same principle

by Tony Hopkinson In reply to the

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

Collapse -

h

by awadaa In reply to same principle

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

Collapse -

Well you should start look at why my answer

by Tony Hopkinson In reply to h

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.

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Forums