hi
I have a huge table like the one at LEFT. For each ID, Rank runs from 0 to 4. The ID increments by 1 after each set of 5 records.
I want to insert a new record at the beginning of each group of 5 records. This is shown at RIGHT. For each of these new records, the last 3 fields are -1, 0, 0.
I'm guessing this involves a UNION query, but I'm rusty enough that I cant get it to work.
Any help is appreciated
Vicky
I have a huge table like the one at LEFT. For each ID, Rank runs from 0 to 4. The ID increments by 1 after each set of 5 records.
I want to insert a new record at the beginning of each group of 5 records. This is shown at RIGHT. For each of these new records, the last 3 fields are -1, 0, 0.
Code:
tbl_OLD tbl_NEW
~~~~~~~ ~~~~~~~
ID Rank X Y ID Rank X Y
=========================== ===========================
1 0 18 96 [b][COLOR=#CC0000]1 -1 0 0[/color][/b]
1 1 65 100 1 0 18 96
1 2 39 50 1 1 65 100
1 3 58 23 1 2 39 50
1 4 25 103 1 3 58 23
2 0 39 50 1 4 25 103
2 1 65 100 [b][COLOR=#CC0000]2 -1 0 0[/color][/b]
2 2 18 96 2 0 39 50
2 3 58 23 2 1 65 100
2 4 25 103 2 2 18 96
3 0 18 96 2 3 58 23
3 1 89 34 2 4 25 103
3 2 25 103 [b][COLOR=#CC0000]3 -1 0 0[/color][/b]
3 3 58 23 3 0 18 96
3 4 39 50 3 1 89 34
3 2 25 103
3 3 58 23
3 4 39 50
I'm guessing this involves a UNION query, but I'm rusty enough that I cant get it to work.
Any help is appreciated
Vicky