I would like to group column values and then order values in another column in ascending order. I don't mind if new table has to be created. Could any one help me with this query please? Database is MySQL.
Thanks so much!
Please see my sample data here.
SID | Area-No | Sub-Area No|
1-------5-----------1------|
2-------4-----------1------|
3-------3-----------2------|
9-------5-----------2------|
5-------6-----------1------|
7-------9-----------3------|
4-------1-----------9------|
6-------1-----------7------|
8-------2-----------1------|
10------2-----------5------|
11------2-----------6------|
12------2-----------2------|
Each SID has an Area-No. There are 1-20+ Areas. Each Area has 1-20+ sub-Areas. I want to group SIDs by Area No, so that table is re-arranged (or may be new table is created) which has first few rows showing only Area 1 and all Sub-Areas under Area 1. Then rows show Area2 and all sub areas under Area 2, so on. I dont mind if SIDs order change.
Output would be:
SID | Area-No | Sub-Area No|
6-------1-----------7------|
4-------1-----------9------|
8-------2-----------1------|
12------2-----------2------|
10------2-----------5------|
11------2-----------6------|
3-------3-----------2------|
2-------4-----------1------|
1-------5-----------1------|
9-------5-----------2------|
5-------6-----------1------|
7-------9-----------3------|
Select returns records to me. But I want to arrange the table itself, not selecting records from it. I dont mind if new table has to be created.
Thanks again!!