MySQL Forums
Forum List  »  General

How do i order by alternating rows (1,2,3,1,2,3,1,2,3 etc)
Posted by: Amit Badkas
Date: January 17, 2013 05:40AM

I have an issue similar to http://forums.mysql.com/read.php?20,536450,536450#msg-536450

Following is the table structure

CREATE TABLE `t` (
`client_id` int(11) NOT NULL,
`project_id` int(11) NOT NULL,
`project_name` varchar(255) NOT NULL
);

And following are records in it

INSERT INTO `t` (`client_id`, `project_id`, `project_name`) VALUES
(1, 42, 'project abc'),
(1, 22, 'project apple'),
(2, 49, 'project xyz'),
(3, 21, 'project banana'),
(3, 41, 'project 123'),
(2, 29, 'project orange');

The output I need should be sorted by client ID 1,2,3 - 1,2,3 ..., something like

client_id project_id project_name
---------- ------------ -----------------
1 | 42 | project abc
2 | 49 | project xyz
3 | 41 | project 123
1 | 22 | project apple
2 | 29 | project orange
3 | 21 | project banana

Thanks in advance

Options: ReplyQuote


Subject
Written By
Posted
How do i order by alternating rows (1,2,3,1,2,3,1,2,3 etc)
January 17, 2013 05:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.