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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:22:11+00:00 2026-05-13T15:22:11+00:00

I am essentially attempting to modify this stored procedure. Modified stored procedure: CREATE PROCEDURE

  • 0

I am essentially attempting to modify this stored procedure.

Modified stored procedure:

CREATE PROCEDURE sp1(d1 date, d2 date, client INT(10))
    declare d datetime;

    create TEMPORARY TABLE foo (d date NOT NULL, Amount INT(10) DEFAULT 0);

    set d = d1;

    while d <= d2 do 
        insert into foo (d) values (d);
        set d = date_add(d, interval 1 day);
    end while;

    SELECT SUM(p.Amount), foo.d
    FROM foo LEFT JOIN ItemTracker_dbo.Payment ON foo.d = p.Datetime
    WHERE p.ClientId = ClientId
    GROUP BY
        foo.d;

    DROP TEMPORARY TABLE foo;
end PROCEDURE

NOTE: the WHERE clause… p.ClientId = client

I was wracking my brain trying to figure out why it was omitting the zero’s.

upon removal of WHERE p.ClientId = client the procedure began to return NULL…

Why is the WHERE clause ommiting the null rows? I am probably misunderstanding what exactly a LEFT JOIN is.

How can I go about filtering the SUM(p.Amount) results to only return the sum WHERE clientId = client?

  • 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-13T15:22:12+00:00Added an answer on May 13, 2026 at 3:22 pm

    It should work if you put all the conditions into the LEFT JOIN condition:

    SELECT SUM(p.Amount), foo.d
    FROM foo
    LEFT JOIN ItemTracker_dbo.Payment p ON foo.d = p.Datetime AND p.ClientId = ClientId
    GROUP BY
        foo.d;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write a CompiledQuery using Linq-to-Entities that will replace a stored procedure
I essentially want to spider my local site and create a list of all
I'm attempting to mangle a SQL query via regex. My goal is essentially grab
I'm attempting to utilize the socket.h functions within Windows. Essentially, I'm currently looking at
I am attempting to create a custom server control CollapsablePanel that extends ASP.net's Panel.
I am attempting to create a simple web app for iPad which needs to
Essentially, I want to be able to do something like this: struct Foo {
I am essentially attempting to replace all of the footnotes in a large text.
I'm attempting to create a small automapper-esq utility that will take a LinqToSql entity
This is the method I am attempting to use whilst trying to send a

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.