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

  • SEARCH
  • Home
  • 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 3239304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:57:16+00:00 2026-05-17T17:57:16+00:00

currently the stored proc returns one record based on a employee_number that is passed

  • 0

currently the stored proc returns one record based on a employee_number that is passed as a parameter. If the surpervisor_id is NULL, there is no record returned. If I want to return a record with all the other fields, and have a NULL in the supervisor_id field, how would I configure that?

SELECT DISTINCT 
    tblPeople.PERSON_ID, tblPeople.FIRST_NAME, tblPeople.LAST_NAME, 
    tblPeople.EMPLOYEE_NUMBER, tblPeople.EMAIL_ADDRESS, 
    tblAddress.ADDRESS_LINE1, tblAddress.ADDRESS_LINE2, tblAddress.ADDRESS_LINE3, 
    tblAddress.TOWN_OR_CITY, tblAddress.STATE, tblAddress.COUNTRY, 
    tblAddress.POSTAL_CODE, tblPeople.PHONE_NUMBER, 
    tblPeople.EFFECTIVE_START_DATE, tblPeople.EFFECTIVE_END_DATE, 
    tblLocation.LOC_CODE, 
    pp2.FIRST_NAME AS Expr1, pp2.LAST_NAME AS Expr2, 
    pp2.EMPLOYEE_NUMBER AS Expr3, tblAssignment.SUPERVISOR_ID, 
    tblAssignment.ATTRIBUTE2, tblAssignment.ATTRIBUTE3, 
    tblPeople.INSTANCE_ID, tblAssignment.LOC_ID
FROM
    tblPeople AS tblPeople 
RIGHT OUTER JOIN
    tblAddress AS tblAddress ON tblPeople.PERSON_ID = tblAddress.PERSON_ID 
                             AND tblPeople.INSTANCE_ID = tblAddress.INSTANCE_ID 
INNER JOIN
    tblAssignments AS tblAssignment ON tblPeople.PERSON_ID = tblAssignment.PERSON_ID 
                                    AND tblPeople.INSTANCE_ID = tblAssignment.INSTANCE_ID 
INNER JOIN
    Locations AS Location ON Location.LOC_ID = tblAssignment.LOC_ID
                          AND Location.INSTANCE_ID = tblAssignment.INSTANCE_ID 
INNER JOIN 
    tblPeople AS pp2 ON pp2.PERSON_ID = tblAssignment.SUPERVISOR_ID
                     AND pp2.INSTANCE_ID = tblAssignment.INSTANCE_ID
WHERE     
    tblPeople.EMPLOYEE_NUMBER = '3298'
    AND tblPeople.INSTANCE_ID = 1
    AND tblAssignment.Assignment_Status = 'Current'
  • 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-17T17:57:16+00:00Added an answer on May 17, 2026 at 5:57 pm

    Most likely, you just need to change this JOIN

    INNER JOIN 
        tblPeople AS pp2 ON pp2.PERSON_ID = tblAssignment.SUPERVISOR_ID
                         AND pp2.INSTANCE_ID = tblAssignment.INSTANCE_ID
    

    to an LEFT OUTER JOIN

    LEFT OUTER JOIN 
        tblPeople AS pp2 ON pp2.PERSON_ID = tblAssignment.SUPERVISOR_ID
                         AND pp2.INSTANCE_ID = tblAssignment.INSTANCE_ID
    

    If that SUPERVISOR_ID IS NULL, then the columns from the pp2 table will be NULL, but you should still get data for all other columns back.

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

Sidebar

Related Questions

I need to create a stored proc that will return records (more than one
I have a SQL stored procedure that will return only one record. However, in
I currently have 2 stored procedures ... Stored Proc #1 returns a list of
I have a database with DateTime fields that are currently stored in local time.
I have a stored procedure currently executing a complicated fetch that is frequently timing
I have a quick linq question. I have a stored proc that should return
I have a stored proc on SQL Server 2000 that takes 3 parameters. When
I have some data that's currently stored in an Excel workbook. It makes sense
I am trying to create a stored procedure that returns the ID of a
I am working with a rather hairy Stored Proc which returns XML (the XML

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.