# Thread: Difference between top with ties and percentage with ties

1. Registered User
Join Date
Aug 2009
Posts
37

## Unanswered: Difference between top with ties and percentage with ties

hi
what is the difference between "top 5 percent with ties" and
"top 5 percent with ties"

Thaks

2. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
Originally Posted by bandiramireddy
between "top 5 percent with ties" and "top 5 percent with ties"
nothing

3. www.gvee.co.uk
Join Date
Jan 2007
Location
UK
Posts
11,445
I'm guessing you actually meant "top 5 with ties" and "top 5 percent with ties"...
Either way it is hard to explain without using the words in the statements themselves!

TOP N = the first N rows of your resultset based on the ORDER BY clause
TOP N PERCENT = the first N percent of rows of your resultset based on the ORDER BY clause

WITH TIES = If the N and N + 1 rows have the same values, show them both (they are equivalent).

This might be better explained with an example...
Code:
```DECLARE @x table (
x tinyint
)

INSERT INTO @x (x)
SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 2
UNION ALL SELECT 3

SELECT TOP 2
x As "Top 2"
FROM   @x
ORDER
BY x

SELECT TOP 2 WITH TIES
x As "Top 2 with ties"
FROM   @x
ORDER
BY x

SELECT TOP 50 PERCENT
x As "Top 50%"
FROM   @x
ORDER
BY x

SELECT TOP 50 PERCENT WITH TIES
x As "Top 50% with ties"
FROM   @x
ORDER
BY x```
Results
Code:
```Top 2
-----
1
2

(2 row(s) affected)

Top 2 with ties
---------------
1
2
2

(3 row(s) affected)

Top 50%
-------
1
2

(2 row(s) affected)

Top 50% with ties
-----------------
1
2
2

(3 row(s) affected)```
Hope this helps!

4. Registered User
Join Date
Jul 2010
Location
ISHHHH
Posts
130
nice its very easy to understand

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•