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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:30:17+00:00 2026-06-17T22:30:17+00:00

I was thinking it might be an issue with the joins? I’ve tried Group

  • 0

I was thinking it might be an issue with the joins? I’ve tried Group by to no avail…
Any advice would be appreicated! I’ve placed the query below:

*Sorry for the lack of details- Med_Prof_Record_No is the unique value, and I know the code is messy- but this is what was here when I got here 😉 Also this is a sql 2000 box, so new syntax won’t work… I’ve cleaned up the joins abit but don’t want to stray too far from the original queries-

SELECT DISTINCT
    P.Last_name + ', ' + P.First_name AS Full_name,   
    P.Degree, 
    F.Med_Prof_Record_No, 
    F.Current_status, 
    F.Status_category, 
    F.Department_name, 
    F.Section, 
    F.SPHAffiliatedPhysiciansSurgeons AS Affiliated,
    S.Board_Name, 
    S.Specialty_Name,
    O.Office_name, 
    O.Address_1, 
    O.Address_2, 
    O.City, 
    O.State, 
    O.Zip_Code, 
    O.Phone_number_1, 
    O.Fax_number
FROM 
    Med_Prof P, Med_Prof_Facilities F, Med_Prof_Specialties S, Med_Prof_Offices O
WHERE         
    (F.Med_Prof_Record_No = P.Med_Prof_Record_No) AND 
    (F.Med_Prof_Record_No = S.Med_Prof_Record_No) AND
    (F.Med_Prof_Record_No = O.Med_Prof_Record_No) AND        
    <cfif URL.LastName is NOT "">(P.Last_name LIKE '#URL.LastName#%') AND</cfif>
    <cfif URL.Specialty is NOT "">(F.Section = '#URL.Specialty#') AND</cfif>
    <cfif URL.Group is NOT "">(O.Office_name LIKE '#URL.Group#%') AND</cfif>                
    (F.Status_category = 'active')
ORDER by Full_name
  • 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-06-17T22:30:18+00:00Added an answer on June 17, 2026 at 10:30 pm

    Here is a stab. This makes assumptions about how you want to decide which office etc. to show (in this case it is as good as arbitrary), that P.Med_Prof_Record_No is unique and only represents one person (at first I thought Last_name + First_name is unique, but that seems a very dangerous assumption), and also that you are using SQL Server 2005 or better. Finally, please use properly qualified object names and please, please, please stop using lazy implicit joins of the FROM foo, bar, blat, splunge variety.

    ;WITH x AS
    (
      SELECT 
        P.Last_name + ', ' + P.First_name AS Full_name,   
        P.Degree, 
        F.Med_Prof_Record_No, 
        -- other columns from F,
        S.Board_Name, 
        S.Specialty_Name,
        O.Office_name,
        -- other columns from O,
        rn = ROW_NUMBER() OVER (PARTITION BY P.Med_Prof_Record_No
          ORDER BY F.Current_status, S.Board_name, O.Office_name)
      FROM 
        dbo.Med_Prof AS P
      INNER JOIN 
        dbo.Med_Prof_Facilities AS F
        ON P.Med_Prof_Record_No = F.Med_Prof_Record_No
      INNER JOIN
        dbo.Med_Prof_Specialties AS S
        ON F.Med_Prof_Record_No = S.Med_Prof_Record_No
      INNER JOIN
        dbo.Med_Prof_Offices AS O
        ON F.Med_Prof_Record_No = O.Med_Prof_Record_No
      WHERE         
        <cfif ... AND</cfif>
        -- other <cfif> clauses
        (F.Status_category = 'active')
    )
    SELECT * FROM x WHERE rn = 1
    ORDER BY Full_name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL design issue. The code below might look a little
This might seem as silly question but I am thinking there might be the
I am making an abstract-base-class and was thinking I might want a pure virtual
I'm making a command-line based tool in Java, and I was thinking I might
Can anyone explain what might be causing this error. Im thinking its the quotes.
Can anyone tell why visiting the below link might lead IE7 to say they
I am facing some critical issue which might be interesting for whom , those
Hola! I have an issue I thought I would throw out to the S.O.
Thinking about avoiding code replication, I got a question that catches me every time
Thinking about if we modify the definition of Hamiltonian path as we need to

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.