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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:11:40+00:00 2026-05-15T09:11:40+00:00

The following code section is returning multiple columns for a few records. SELECT a.ClientID,ltrim(rtrim(c.FirstName))

  • 0

The following code section is returning multiple columns for a few records.


SELECT a.ClientID,ltrim(rtrim(c.FirstName)) + ' ' +

case when c.MiddleName <> '' then
ltrim(rtrim(c.MiddleName)) + '. ' 
else '' 
end +

ltrim(rtrim(c.LastName)) as ClientName, a.MISCode, b.Address, b.City, dbo.ClientGetEnrolledPrograms(CONVERT(int,a.ClientID)) as Abbreviation
FROM ClientDetail a
JOIN Address b on(a.PersonID = b.PersonID)
JOIN Person c on(a.PersonID = c.PersonID)
LEFT JOIN ProgramEnrollments d on(d.ClientID = a.ClientID and d.Status = 'Enrolled' and d.HistoricalPKID is null)
LEFT JOIN Program e on(d.ProgramID = e.ProgramID and e.HistoricalPKID is null)
WHERE a.MichiganWorksData=1

I’ve isolated the issue to the ProgramEnrollments table.
This table holds one-to-many relationships where each ClientID can be enrolled in many programs. So for each program a client is enrolled in, there is a record in the table.

The final result set is therefore returning a row for each row in the ProgramEnrollments table based on these joins.

I presume my join is the issue but I don’t see the problem.

Thoughts/Suggestions?

Thanks,

Chuck

  • 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-15T09:11:41+00:00Added an answer on May 15, 2026 at 9:11 am

    The JOIN is not the issue, it’s doing what it’s meant to do with a one-to-many relationship

    You could use a GROUP BY statement on your query, or alternatively use a sub-select to return DISTINCT values from the ProgramEnrollments/Program tables.

    You don’t seem to be using data from the ProgramEnrollments or Program tables so are they needed in the query (I presume they are, just thought I’d ask the question).

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

Sidebar

Related Questions

I have the following code in the columns section of my GridView: <Columns> <asp:boundfield
I'm wondering why this code section prints out the following: print request.user.has_perm('bug_tracking.is_developer'): + str(request.user.has_perm('bug_tracking.is_developer'))
I have the following section of code in an app that I am writing:
Placing the following code inside the 'markup' section on a web form does not
I have the following code section, designed to count how many Excel processes are
I have the following code var section = new CustomConfigurationSection(); section.SectionInformation.Type = System.Configuration.NameValueFileSectionHandler; section.SectionInformation.SetRawXml(sectionXml);
I've got the following code which should put an image in the top section/cell
I'm using the following section of code to display some icons on our Magento
I have the following code: @section ftr_scripts { <script src=//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js type=text/javascript></script> } Under the
The C# 3.0 spec has the following code example in section 10.6.1.3 Output parameters:

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.