List Display---first even then odd

There is a scenario: Display the list data in the order-first even position rows and then odd position rows.....Can anyone help on this issue..

Questions by jjrkl_sandeep   answers by jjrkl_sandeep

Showing Answers 1 - 2 of 2 Answers

Gajendra kumar

  • Nov 28th, 2013

First check based on which column the odd and even value should come.

For example in a list EVEN EMP_ID should display first and than ODD EMP_ID.

Now drag this column to query subject.

Create another dataitem, for example name as EMP_SRT.
The expression inside this EMP_SRT should be MOD(EMP_ID,2).

Now add this EMP_SRT to the list. Now select the list and do sorting, the sorting order should be EMP_SRT as first level and EMP_ID as second level of sorting.

Now set BOX TYPE as None for this EMP_SRT column.
Usually if we use MOD, if the number is divisible the value is 0 and if not it is 1. So that if u sort as ascending first all even numbers will get listed with 0 MOD value and than ODD values with 1 value.

Soumyadeb Halder

  • Feb 17th, 2014

Suppose your table is "employee" and column name is "empid" .

Now you want a list which contains EVEN empids first and then ODD empids.

Your query will be like below,
Select empid from employee order by Mod(empid,2),empid;

IF you want a list which contains ODD empids first and then EVEN empids.

Your query will be like below,
Select empid from employee order by Mod(empid,2) desc ,empid;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions