【问题】
how to move two column data to one column data
Hi,
I have users that belongs to groups. I need to make both data in one column and specify if this is group or user.
Source data in “mytable” are:
Code:
ColGroup ColUser
Group1 User1
Group1 User2
Group2 User3
Group2 User4
...
Note: list of groups and users is longer than this simple sample. Each user can belong only to one group (ColUser is PK in table). Groups can have multiple users.
Result of SQL should be:
Code:
ColGroupUser UserType
Group1 group
User1 user
User2 user
Group2 group
User3 user
User4 user
...
Note: first is Group1, then there are listed all users that belongs to Group1 in our sample there are User1 and User2. Then must be displayed Group2 and after that all users that belongs to Group2 that are User3 and User4.
Question: how to write such an SQL to move