Hi guys,
Suppose I have a table like this:
hseid | projcode | bulidarea | room | hall | floor | totalfloor | price
0 | 1 | 100 | 1 | 1 | 9 | 25 | 100
1 | 2 | 99 | 1 | 1 | 9 | 25 | 100
2 | 2 | 101 | 1 | 1 | 9 | 25 | 100
3 | 4 | 110 | 1 | 1 | 9 | 25 | 100
4 | 3 | 130 | 1 | 1 | 9 | 25 | 100
5 | 1 | 95 | 1 | 1 | 9 | 25 | 100
6 | 4 | 98 | 1 | 1 | 9 | 25 | 100
7 | 3 | 101 | 1 | 1 | 9 | 25 | 100
Note that hseid represented as unique building, projcode represents different property project developers, and the rest fields are not important.
Now to balance the argument among property project developers, I should make the result looks like this:
hseid | projcode | bulidarea | room | hall | floor | totalfloor | price
0 | 1 | 100 | 1 | 1 | 9 | 25 | 100
1 | 2 | 99 | 1 | 1 | 9 | 25 | 100
4 | 3 | 130 | 1 | 1 | 9 | 25 | 100
3 | 4 | 110 | 1 | 1 | 9 | 25 | 100
5 | 1 | 95 | 1 | 1 | 9 | 25 | 100
2 | 2 | 101 | 1 | 1 | 9 | 25 | 100
7 | 3 | 101 | 1 | 1 | 9 | 25 | 100
6 | 4 | 98 | 1 | 1 | 9 | 25 | 100
Basically the rule is:
- Rotate each projcode
- In each projecode, randomly pick one which is not already showed.
How do I implement this in MySQL?
Thanks a lot.