Assuming you're doing this by department, try to get just a list of the 
distinct salary rankings into an inline view, using your count(*) +1 
approach to set the salary rank,  where these three columns are unique 
in combination:


(dept, salary, rank ) as S


and then :

select EE.dept, EE.name, EE.salary, S.rank
from employees as EE
JOIN
(inline view to create distinct salary bands by department goes here) as S
on EE.dept = S.dept
and EE.salary = S.salary
order by dept, rank


If you make the innermost inline view (select distinct dept, salary....) 
and then use an outer to set the salary-band rankings within department, 
you will be working with far fewer than 200,000 rows, and the 
salary-bank rankings-by-department inline view will probably be held in 
a transient table and used as the inner loop. I would put an index on 
dept and salary in the EEs table.

Regards
Tim Romano

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to