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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toppercent syntax

Status
Not open for further replies.

grecian9

IS-IT--Management
Dec 4, 2002
8
0
0
GB
Hi, this should be easy for someone. I don't understand the syntax for toppercent. According to the help menu the syntax is TopPercent(«Set», «Percentage», «Numeric Expression»).

Where in this syntax do you specify the column you want to sort on? Some demo syntax would be great.

Thanks

 
Which database are you using? It doesn't sound like SQL Server. You could try posting in the appropriate forum for a better answer. --James
 
Well, in SQL Server it's:

SELECT TOP 50 PERCENT
FROM myTable
ORDER BY myColumn

but the phrasing of your question makes me wonder whether you're using SQL Server...

Do tell :)

Graham
 
It is in fact SQL server 2000. If you look up toppercent in the help menu you will find the syntax I included.
 
Yes indeed - my apologies, this is a new one on me. Presumably since this is a function that returns a table type, you could order the results selected from it by any valid column thus:

select * from TopPercent([Products], [Unit Sales], 60)
order by [unit sales]

(following the example given in BOL2k.

Can anyone confirm?
 
TopPercent is an Analysis Services function. Is that what you want to know about or do you want to know how to use the TOP key word in a T-SQL statement? The syntax for both are explained in SQL BOL. If you want to get the best answer for your question read faq183-874 and thread183-468158.
Terry L. Broadbent - DBA
SQL Server Page:
 
Apologies grecian9, I don't have much experience with analysis services so I was unfamiliar with that function.

Perhaps someone else could shed some light? --James
 
The answer is " I don't know". I just wanted to take the top 10% of a certain column from one table. It sounds easy but appears not to be.
 
To select the top 10% of table 'myTable', column 'myColumn':

SELECT TOP 10 PERCENT myColumn
FROM myTable

It seems you were after the TOP operator after all.

HTH,

Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top