|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sql Statement (select Top)
TableA:
Country CountItem CatDescription ----------------------------------- Hong Kong 50 Gifts Premium Hong Kong 2 Literature Hong Kong 2 Advertisement Hong Kong 1 Sports Australia 8 Gifts Premium Australia 5 Sports I would like to query it to have result below. How to query? (Select only Top 3- based on CountItem DESC) Country Top1 Top2 Top3 ----------------------------------------------------- Hong Kong Gifts Premium Literature Advertisement Australia Gifts Premium Sports -nil- Pls help. Thanks |
|
#2
|
||||
|
||||
|
i don't think this can be done by an SQL statement, you'll need a function or stored procedure for thing (and not a small one)
|
|
#3
|
|||
|
|||
|
select the records TOP2
But Is it possible If I select only one records of the TOP 2?
|
|
#4
|
||||
|
||||
|
selecting the max, min or top is no problem
its the horizontal movement (the top 3 in 3 record) that is difficult so things like this: PHP Code:
are no problem, but things like this PHP Code:
can give you migraines |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Sql Statement (select Top) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|