Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select first 50 rows of a sorted recordset by value desc. 1

Status
Not open for further replies.

johnvai

IS-IT--Management
Oct 4, 2003
127
0
0
LB
Dear Friends:

I have a question, which i am not sure if it works in sql.
i have member names in a table with their number of orders field.
MEMBERS
-------
ID
MEMNAME
NUMOFDEL

I want to show the first 50 members having the maximum number of orders (NUMOFDEL) grouped as well by MEMNAME or ID.
Example:
1 JOHN 500
2 DANY 490
3 MIRA 490
4 ISAAC 375
:
:
:
50 FRED 150

Thanks.
 
Hi JohnVai,

I think this will be of help for you.
If you only want to show the first 50 rows then try

set rowcount <<50>>
select * from <<TABLEA>> order by <<column1 desc>>
set rowcount <<0>>

The set rowcount will assure that only the number of rows mentioned in the statement will be returned when the subsequent SQl statement is executed. We can then set the rowcount to 0 so that the other sql statements are not affected.

Replace the values between <<>> with your own.

Cheers,
KK
 
Thanks man!
This is what i wanted!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top