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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:44:58+00:00 2026-06-11T11:44:58+00:00

Someone has written the following stored proc query (I have removed all the irrelevant

  • 0

Someone has written the following stored proc query (I have removed all the irrelevant code to make things easier to read)

 SELECT           
   CRL.ClientNum ,    
            ..."A lot of columns"...,
   ISNULL((SELECT SUM(Amount) FROM db..History dh (nolock) WHERE dh.id = dd.Id AND ActivityId = 11), 0.00) AS [Some Amt],    
            ..."A lot more columns"...        
   FROM db..[SomeLog] SL  
            ..."A lot of inner joins and left joins"...             
   where clause
   order by clause 

This all okay but, now I need to put in a Case statement to select/compare columns from The “db..History” table. The issue is there is no existing join on this table.

  • I have tried putting in an inner join on the “db..History” table but this returns a lot more rows than it should. Most likely because there are multiple “Histories” for the table its joining on.
  • I thought about using a temp table at the start to store the “db..History” table values but this required doing a lot of inner joins to get the data and would be performance hit.
  • 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-11T11:44:59+00:00Added an answer on June 11, 2026 at 11:44 am

    Maybe your inner join isn’t correct, however, you can create a view of your necessary tables & fields and implement a join on that. in most situation using visual tools(shown in the above link) to create a view is easier and better than writing code.

    Most join problems are because of creating tables incorrectly. If you create tables distributed truly and clear, it can help you a lot.

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

Sidebar

Related Questions

I have the following segment of code that someone else has written, and that
I have written following code: public ActionResult Index() { var folders = Directory.GetDirectories(Server.MapPath(~/Content/themes/base/songs)); foreach
The NetHack source code (written in C) has some things I don't understand. The
I have a dll written by someone else and that has many flaws. Let's
Is there a way through the .Net aframework (or has someone written something similar)
I'm modifying a Firefox extension that has been written by someone else, and I'm
Someone has an answer to this missing feature in Entity Framework. Does anyone have
Hope someone has an easy answer on this. I have a header image which
Someone has reported a bug in my program, which brings up the following error
I have question on usage java nio and hope someone who has a lot

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.