Hi All,
I have a table called Sales_Data bu division /Region and Team wise. I would like to find the hierarchy with the levels by division/Region and team wise.
Here am posting the sample data. Could you please find the data and advise, how can we write a query to find the hierarchy for division--> Region---> Team.
[code]
| ID | KEY | DIVNAME | DIVMANAGER | RegionName | RegionManager | TeamName | TeamManager | Sales_REPR |
| | | | | | | | | |
| 67 | 1-2EO4XZ | Central | RSPITZ | Cincinnati | DGENSLER | Prenger | BPRENGER | NFERRITTO |
| 68 | 1-3BA8BX | Central | RSPITZ | Cincinnati | DGENSLER | Prenger | BPRENGER | NJACKSON |
| 69 | 1-3IX60I | Central | RSPITZ | Cincinnati | DGENSLER | Prenger | BPRENGER | OMELTON |
| 70 | 1-2F9G75 | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | AONDIK |
| 71 | 1-2Z7GX3 | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | KHOFFMAN |
| 72 | 1-1J6QHH | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | KQUINN |
| 73 | 1-2ZOBE5 | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | KRAKOTCI |
| 74 | 1-FOLMV | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | NSORENSEN |
| 75 | 1-47AZVT | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | PTIMKO |
| 76 | 1-2ZLUQ1 | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | SKENNEDY |
| 77 | 1-3O6PJW | Central | RSPITZ | Cincinnati | DGENSLER | Trussell | CTRUSSELL | SKOSCIELSKI |
| 78 | 1-40STK9 | Central | RSPITZ | Cincinnati | DGENSLER | Vargo | AVARGO | MKRYSTOFIK |
| 79 | 1-GSCZS | Central | RSPITZ | Cincinnati | DGENSLER | Vargo | AVARGO | NERBY |
| 80 | 1-3Y5U8Q | Central | RSPITZ | Cincinnati | DGENSLER | Vargo | AVARGO | TVOURAX |
| 81 | 1-S2357 | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | ACOWLEY |
| 82 | 1-2Z0B4A | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | ADAWSON |
| 83 | 1-2PVH6G | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | DDAILEY |
| 84 | 1-86EOD | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | KSCHMIDT |
| 85 | 1-2YVCAR | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | KWILLIAMS |
| 86 | 1-1LU7NA | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | MLARIVEE |
| 87 | 1-LJ7YG | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | MMCKIRNAN |
| 88 | 1-T1AYZ | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | MMEYERS |
| 89 | 1-3D9QP | Central | RSPITZ | Cincinnati | DGENSLER | Wackman | TWACKMAN | TWACKMAN |
| 90 | 1-4YYS1V | Central | RSPITZ | Cincinnati | DGENSLER | Warner | SWARNER | DKIRKEGAARD |
| 91 | 1-3O6PG1 | Central | RSPITZ | Cincinnati | DGENSLER | Warner | SWARNER | EPANKE |
| 92 | 1-4M2X9R | Central | RSPITZ | Cincinnati | DGENSLER | Warner | SWARNER | MDONNELLY |
| 93 | 1-4ZE634 | Central | RSPITZ | Cincinnati | DGENSLER | Warner | SWARNER | MMILLS |
| 94 | 1-4HDA5N | Central | RSPITZ | Cincinnati | DGENSLER | Warner | SWARNER | PYEE |
| 95 | 1-LGCGF | Central | RSPITZ | Kimberly Clark Group | TBEDELL | Bedell | TBEDELL | ABAUMANN |
| 96 | 1-BFNAS | Central | RSPITZ | Kimberly Clark Group | TBEDELL | Bedell | TBEDELL | CDWYER |
| 97 | 1-B2E8T | Central | RSPITZ | Kimberly Clark Group | TBEDELL | Bedell | TBEDELL | JKAETZEL |
| 98 | 1-FNAV0 | Central | RSPITZ | Minneapolis | ATOPP | Topp | ATOPP | AERICKSON |
| 99 | 1-A5JL1 | Central | RSPITZ | Minneapolis | ATOPP | Topp | ATOPP | CSKOWRONSKY |
| 100 | 1-BBNUU | Central | RSPITZ | Minneapolis | ATOPP | Topp | ATOPP | DWIEGRATZ |
| 101 | 1-751E7 | Central | RSPITZ | Minneapolis | ATOPP | Topp | ATOPP | EWESELY |
| 207 | 1+16+74 | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Business Development | RKOVALESKY | CHAMILTON |
| 208 | 1-ED9QP | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Business Development | RKOVALESKY | JBOWE |
| 209 | 1-74THN | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Business Development | RKOVALESKY | LPARNES |
| 210 | 1-7MOQ7 | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Business Development | RKOVALESKY | NBEVINS |
| 211 | 1+16+194 | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Business Development | RKOVALESKY | RSTEWART |
| 212 | 1-22507 | Business Development | RKOVALESKY | Business Development | RKOVALESKY | Henderson | GHENDERSON | CWILLIAMS |
| 213 | 1-KYCWT | Canada | ANORTH | Canada | ANORTH | Custeau | CCUSTEAU | DSAUVE |
| 214 | 1-AURGN | Canada | ANORTH | Canada | ANORTH | Custeau | CCUSTEAU | MKARASSEFERIAN |
| 215 | 1-9HLL9 | Canada | ANORTH | Canada | ANORTH | Davis | MDAVIS | ACHEN |
[/code]
ID column is Unique number generator. I would like to find the level of the above data based on their DIVNAME and REGNAME and the TEAMNAME
and I don't have any test case to post here.. apart from this data..
Please advise a query to find the level of the hierarchy.