MySQL查询打印每个奇数行

时间:2016-10-15 19:51:03

标签: mysql

我有以下查询。我只是希望我的查询返回每个奇数行,即行号1,3,5 ......等等。目前它正在返回上述满足条件的所有行。

select d.name as dept_name,count(*) as emp_number,sum(e.salary) as total_salary
from Employee e inner join Department d on  d.id=e.department 
group by department having count(*)<6 
order by sum(salary) desc, count(*) desc, department asc;

1 个答案:

答案 0 :(得分:0)

在查询中使用mod函数或%运算符来标识偶数/奇数行。

请参阅此前提出的问题:

Select only even/odd rows in MySQL