1

Topic: There is a table of the goods, it is necessary to make grouping on shops shop_id with alternation

There is a table of the goods, it is necessary to make grouping on shops user_id with alternation
Prompt please, idea
There is a table of the goods goods the goods

CREATE TABLE IF NOT EXISTS ` goods ` (
` id ` int (11) unsigned NOT NULL AUTO_INCREMENT, - id the goods
` pid ` int (11) unsigned NOT NULL DEFAULT ' 0 ', - id groups of type bicycles
` name ` varchar (250) NOT NULL DEFAULT ", - goods title
` price ` float (11,2) unsigned NOT NULL DEFAULT ' 0.00 ', - the price
` user_id ` int (11) NOT NULL DEFAULT ' 0 ', - id the user who has added the goods
` sort ` int (4) DEFAULT ' 0 ', - an urgency of the goods (price), in general date of acknowledgement of the goods
PRIMARY KEY (` id `);
KEY ` pid ` (` pid `);
KEY ` user_id ` (` user_id `)
);

--
--  the table data ` goods`
--

INSERT INTO ` goods ` (` id `, ` pid `, ` name `, ` price `, ` user_id `, ` sort `) VALUES
(1, 2, ' the Bicycle 1 ', 5.00, 2, 1);
(2, 3, ' the Bicycle 2 ', 2.00, 1, 22);
(3, 2, ' the Bicycle sports ', 33.00, 1, 3);
(4, 3, ' the Bicycle mountain ', 11.00, 2, 12);
(5, 3, ' a Hitachi Bicycle ', 5.00, 2, 5);
(6, 3, ' Bicycle AMG ', 123.00, 2, 8);
(7, 2, ' the Bicycle 22 ', 45.00, 3, 4);
(8, 3, ' the Bicycle 33 ', 12.00, 3, 12);
(9, 3, ' the Bicycle abrupt ', 5.00, 2, 8);
(10, 2, ' the Bicycle children's ', 2.00, 1, 2);
(11, 3, ' the Bicycle collapsible ', 33.00, 1, 4);
(12, 2, ' the Bicycle mountain 52 ', 11.00, 3, 89);
(13, 2, ' a Sony Bicycle ', 52.00, 2, 45);
(14, 3, ' BMW Bicycle ', 12.00, 3, 38);
(15, 2, ' Bicycle BMX ', 15.00, 3, 42);
(16, 2, ' Bicycle SPORT ', 25.00, 2, 14);
(17, 3, ' Bicycle ABC ', 48.00, 3, 24);
(18, 3, ' Bicycle Region ', 47.00, 1, 34);
(19, 2, ' Bicycle Start ', 13.00, 1, 19);

It is necessary to receive result, groupings on user_id, with alternation on max (sort) in each group

 id pid name user_id sort
1 2 The Bicycle 1 2 1
10 2 The Bicycle children's 1 2
7 2 The Bicycle 22 3 4
5 3 A Hitachi Bicycle 2 5
11 3 The Bicycle collapsible 1 4
8 3 The Bicycle 33 3 13
9 3 The Bicycle abrupt 2 8
3 2 The Bicycle sports 1 3
17 3 Bicycle ABC 3 24
6 3 Bicycle AMG 2 10
19 2 Bicycle Start 1 19
15 2 Bicycle BMX 3 42
4 3 The Bicycle mountain 2 12
2 3 The Bicycle 2 1 22
14 3 BMW Bicycle 3 38
16 2 Bicycle SPORt rr 2 14
18 3 Bicycle Region 1 34
12 2 The Bicycle mountain 52 3 89
13 2 A Sony Bicycle 2 45 

Type it is deduced the actual goods, with grouping on each user. It is desirable to receive the decision. Which would allow to do on a site .
Thankful in advance for your helps.