Top 3 values tie breaker

  • Thread starter Thread starter Manuel
  • Start date Start date
M

Manuel

In returning a top values query, I need to have only
the "top 3 values" returned even in the case of a tie.
Here is an example of what I am trying to do:

Product Count
A 6
B 2
C 2
D 5
E 2
F 1

When using the Top values to return the top 3 I get

Product Count
A 6
D 5
B 2
C 2
E 2

I am not concerned with C or E just the first occurence of
the tie which in this case would be B.

Product Count
A 6
D 5
B 2

Is this possible to achieve.

Any help is appreciated.
Thanks in advance,
Manuel
 
Assuming Product is unique, you might simply add it to your ORDER BY clause,
as in:

SELECT TOP 3
[Your Table].*
FROM
[Your Table]
ORDER BY
[Your Table].[Count] DESC,
[Your Table].[Product]
 
Thanks Brian, that did it. I appreciate your help!!

Manuel
-----Original Message-----
Assuming Product is unique, you might simply add it to your ORDER BY clause,
as in:

SELECT TOP 3
[Your Table].*
FROM
[Your Table]
ORDER BY
[Your Table].[Count] DESC,
[Your Table].[Product]

In returning a top values query, I need to have only
the "top 3 values" returned even in the case of a tie.
Here is an example of what I am trying to do:

Product Count
A 6
B 2
C 2
D 5
E 2
F 1

When using the Top values to return the top 3 I get

Product Count
A 6
D 5
B 2
C 2
E 2

I am not concerned with C or E just the first occurence of
the tie which in this case would be B.

Product Count
A 6
D 5
B 2

Is this possible to achieve.

Any help is appreciated.
Thanks in advance,
Manuel


.
 
Back
Top