I have a database table that's set up as the following:
A | B | C | D | E |
1 | 1 | 0 | 1 | 1 |
1 | 0 | 1 | 1 | 2 |
2 | 1 | 0 | 2 | 3 |
2 | 0 | 1 | 2 | 4 |
3 | 1 | 0 | 3 | 5 |
3 | 0 | 0 | 3 | 6 |
3 | 1 | 0 | 4 | 7 |
3 | 0 | 0 | 4 | 8 |
D represents a group, while E represents is a UNIQUE id in order of occurrence. What I'm trying to create is a query that will return the results of columns B or C, in order of D, A, and then E.
Obviously rows 1&2 are related with the value 1 in the D column, as are 3+4 with the value 2, and 5,6 with the value of 3, and then 7,8.
What's the best way to go about this? I've thought about grouping row D first and then running a separate query to grab A and D Where D = 'D' ORDER BY E, but that only seems to solve part of my issue. Needless to say I'm figuring there has to be a better way of going about this.
Thanks in advance for your assistance.