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 6883179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:20:57+00:00 2026-05-27T05:20:57+00:00

To anyone who can help. I am not an expert at T-SQL so I

  • 0

To anyone who can help. I am not an expert at T-SQL so I am coming here for some guidance. I have a Common Table Expression with two columns that have user id’s. I need to get the name from the user table based on those ID’s so I display the name. Using my CTE with INNER JOINS reduce my record count and I do not know why.

UPDATE I am sorry I should have been more clear. No error. Unexpected results. Before the joins I was returning 135 records. With the joins I get 6.

Here is the SQL:

;WITH CTE
    AS (SELECT *,
            ROW_NUMBER() OVER (PARTITION BY [ChangeRequests].[F0] 
                                    ORDER BY [ChangeRequests].[F8] DESC) AS RN
        FROM [S37] AS [ChangeRequests])
SELECT [CTE].[F0] AS [ID]
    ,[CTE].[F8] AS [RevisionNumber]
    ,[CTE].[F18] AS [ChangeNumber]
    ,[CTE].[F19] AS [Synopsis]
    --,[CTE].[F30] AS [Responsibility]
    ,[CTE].[F32] AS [Description]
    ,(CASE [CTE].[F42] WHEN 0 THEN NULL ELSE dbo.ConvertSTTimestamp([CTE].[F42]) END) AS [EnteredOn]
    ,[CTE].[F51] AS [Usr_Project]
    --,[CTE].[F52] AS [Usr_CoResponsibility]
    ,[CTE].[F59] AS [Usr_ReportedBy]
    ,[CTE].[F61] AS [Usr_StarFlowStatus]
    ,[Users1].[F7] AS [Responsibility]
    ,[Users2].[F7] AS [CoResponsibility]
FROM CTE
INNER JOIN [S3] [Users1] ON [Users1].[F0] = [CTE].[F30]
INNER JOIN [S3] [Users2] ON [Users2].[F0] = [CTE].[F52]
WHERE (RN = 1)

How do I do a JOIN based on my 2 user ID columns to get the user name?

Thanks!

  • 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-27T05:20:58+00:00Added an answer on May 27, 2026 at 5:20 am

    Change the INNER JOINs to LEFT JOINs, and tell us what you get, and if it’s any closer to what you want/expect…

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

Sidebar

Related Questions

To anyone who can help. I am not an expert at T-SQL so I
To anyone who can help, Thanks Okay, so I have a database holding a
and thanks to anyone who can help me! I have a text with this
I hope there's a SharePoint expert here on SO who can help with this.
internet cake for anyone who can help me with this. I have a long
Thanks in advance to anyone who can help. I've been searching for an answer,
I have a problem that I cannot resolve, so if is anyone who can
Anyone who can answer my question deserves a BIG FAT GOLD MEDAL OF AWESOMENESS!
Thanks in advance to anyone who can think of a more efficient or a
(Bonus internets for anyone who can explain how I can do this in both

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.