Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6797591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:37:38+00:00 2026-05-26T18:37:38+00:00

TerritoryId, Description, ParentTerritoryId, Type ——————————————————– 1, UnitedStates, null, Territory 1, John Smith, 1, Sales

  • 0
    TerritoryId, Description, ParentTerritoryId, Type 
--------------------------------------------------------
    1, UnitedStates, null, Territory 
    1, John Smith, 1, Sales Rep 
    2, Georgia, 1, Territory
    2, Jane Doe, 2, Sales Rep 
    2, Ann Smith, 2, Sales Rep

How can I write the following T-SQL? Let’s say I’m searching for a name like “Ann Smith”.

I’d like the resultset to look like:

1, United States, null, Territory
2, Georgia, 1, Territory
2, Ann Smith, 2, Sales Rep

Basically, I want to find a sales rep or sales reps and what organization they belong to all the way up the chain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:37:38+00:00Added an answer on May 26, 2026 at 6:37 pm

    While it is possible to have a multilevel structure in the table ideally you would want to split your table.

    one table for territory and one for sales reps.

    If your sales reps can have more than one territory you would need to go to 3 tables
    one for sales reps, one for territory, and a lookup table.

    if you are going to do a multi level table you need each entry to have a unique id

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following models: class Territory(models.Model): name = models.CharField(max_length=30) power = models.ForeignKey(Power, null=True,
I have small app in that I manage sales territories. One territory can have
My company uses a sales model of dealers, territory managers and regional managers, each
I have two tables; Leads, Territories and Referrers. Lead has columns: ID, Name, TerritoryId
This is my JSON data: { ACT: Australian Capital Territory, NSW: New South Wales,
Here's the relevant code: public static void printBoarders (Territory x) { int t =
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Hi i am working on an internet explorer automation and this is new territory
This is somewhat new territory for me. I'm using MVC3 with SQL CompactEdition version
That simple. Moving my layout into a fluid territory, working on scalable images. Using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.