Saturday, 16 December 2017

Find n'th highast salary in mysql

select salary from employee ORDER BY salary DESC limit 1,1; or
select salary from employee ORDER BY salary DESC limit 1,n'th;

fist 1 is skip row and second 1 is how many result you want, if you want top 5 then just use 0,5.

No comments:

Post a Comment

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...