Post hoc comparisons. How to do the grouping?

Hi all,
Can anyone help me trying to understand how to do the grouping at the end of the post-hoc procedure in the one way ANOVA?
For each kind of test (LSD, Bonferroni, Tukey, Scheffé etc) I can understand the way it calculates the confidence interval and how it check if the means of each comparison are equal or not but I still don't understand how the groups are made.
I attached a brief example performed with SPSS with 1 factor with 8 levels and a continuous dependent variable. Looking at each comparison I would have make the group in the following way:
- 1,2,3,6,7
- 1,2,3,6,7,8
- 4,5,6,7,8
- 1,3,4,5,6,7,8

Obvioussly I made a mistake because my groups are different from the ones obtained with SPSS (what is also strange, actually, is that SPSS gives results different also from Minitab!).
Can you help me please?
Thank you everybody.