-1

I have the following query. I just want my query to return every odd rows, i.e. row number 1,3,5... so on. At present it is returning all the rows of the above fulfilled condition.

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;
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
65th bit
  • 55
  • 1
  • 11
  • Which field contains the row numbers you want the odd values for? Remember, a database does not have to return rows in any particular order, and the order can/will change with database updates. – Jason Oct 16 '16 at 07:18

1 Answers1

0

Use mod function or % operator inside the query to identify even/odd rows.

Refer to this previously asked question:

Select only even/odd rows in MySQL

Community
  • 1
  • 1
Bambang
  • 391
  • 1
  • 10