Quote:
|
Originally Posted by Brett Kaiser
I know I've seen this work somehow though
|
yeah, it's tricky
here's what you were searching for --
Code:
select a.EmpId
, a.SiteId
, a.sales
from myTable99 a
inner
join myTable99 b
on a.EmpId = b.EmpId
and a.Sales <= b.Sales
group
by a.EmpId
, a.SiteId
, a.sales
having count(*) <= 3
order
by a.EmpId
, a.sales desc
which produces the following (correct) results:
Code:
1 4 50.0000
1 3 20.0000
1 2 15.0000
2 4 5000.0000
2 3 2000.0000
2 2 1500.0000
3 4 5.0000
3 3 2.0000
3 2 1.5000
pat, i like the subquery method too, i guess i just got used to the join solution after so many times showing pre-4.1 mysql people how to do it
