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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:49:37+00:00 2026-06-02T07:49:37+00:00

Edit: nevermind, figured it out, answer below if you’re interested. Using Postgresql 8.4. Here’s

  • 0

Edit: nevermind, figured it out, answer below if you’re interested.

Using Postgresql 8.4.

Here’s the format of the query I need to run (names and faces have been changed to protect my paranoia. they can be provided if necessary, but this is a direct copy of my query with simple substitution for schema, table and column names):

SELECT
    t1.field,
    SUM(v3.quantity) as current_qty
FROM
    schema1.child_table t1
        JOIN (SELECT DISTINCT t1key FROM schema2.child_transaction t2 WHERE datefield BETWEEN '2012-04-01' AND '2012-04-19') t2 USING (t1key)
        LEFT JOIN schema1.child_current_status v3 ON t1.t1key = v3.t1key
        JOIN schema1.parent_table t4 ON t1.t4key = t4.t4key
WHERE
    t4.criteria = 763
GROUP BY
    t1.field

… basically, I need the field from child_table when criteria matches my provided data in parent_table, and when there is at least one relevant transaction in child_transaction during the requested period. If there are quantities in the child_current_status view, we want those as well.

t1.field can be considered a human readable equivalent to numeric key t4.criteria.

My problem is that the query as provided fails to provide quantity data from child_current_status even when there is data there.

Edit: to clarify, the above query returns field, NULL, where it should return field, current_qty

The problem is related to the t2 subquery, because when I change that to a LEFT JOIN, it returns the relevant quantity data:

SELECT
    t1.field,
    SUM(v3.quantity) as current_qty
FROM
    schema1.child_table t1
        LEFT JOIN (SELECT DISTINCT t1key FROM schema2.child_transaction t2 WHERE datefield BETWEEN '2012-04-01' AND '2012-04-19') t2 USING (t1key)
        LEFT JOIN schema1.child_current_status v3 ON t1.t1key = v3.t1key
        JOIN schema1.parent_table t4 ON t1.t4key = t4.t4key
WHERE
    t4.criteria = 763
GROUP BY
    t1.field

Edit: this modified query returns field, current_qty, but will do so whether there are transactions in child_transaction for the requested time period or not

… all I’ve done is turn the first JOIN into a LEFT JOIN, and that query returns with the relevant quantities in child_current_status. If I change the child_current_status to an INNER JOIN, the query returns nothing. The problem with making the first JOIN a LEFT JOIN is that I need it to only return results when there is data returned from the sub query, which there is in this case for the requested time period.

To muddy the waters, it works properly for some t4.criteria, 763 is just one that it fails on.

What am I missing here?


Short version: From the first query above, when the first JOIN is an INNER JOIN, it causes the LEFT JOIN to return nothing. When it’s a LEFT JOIN, the LEFT JOIN on child_current_status returns the proper data, but that negates the purpose of the first JOIN.

Edit: I’ve tried moving the LEFT JOIN to the end of the FROM clause, behind the INNER JOINs, with no change

  • 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-02T07:49:39+00:00Added an answer on June 2, 2026 at 7:49 am

    Ugh, nevermind, I figured it out, the query is working properly and there’s not enough data here for anyone else here to figure it out. Basically, there is one transaction for one child in the child_table, and there are current quantities for other children in the child_table. So the query appropriately indicates that there are no current quantities for any children for which there was a transaction during the specified time for the specified parent.

    The problem came up because in processing the result of this query, I went back and asked for current data relating to all children (rather than just the ones with relevant transactions, like I should have), and got information even when this query (correctly) told me there was none.

    Nothing to see here, move along.

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

Sidebar

Related Questions

** EDIT ** Nevermind, just needed to take out the parens... I get this
EDIT: Never mind. Figured out the issue. Just made height an array and name
-edit- nevermind i was lucky and didnt need to change much and have this
EDIT: I have figured out my main issue, but still have one concern. Everything
-edit- nevermind, i made a mistake in my select statement. Update was working correctly.
EDIT: Here's my call stack. System.ServiceModel.dll!System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(System.ServiceModel.Channels.Message reply, System.ServiceModel.Channels.MessageFault fault, string action, System.ServiceModel.Channels.MessageVersion version, System.ServiceModel.Channels.FaultConverter
-edit- nevermind. I ran the code again and it appears i cant log into
edit: Nevermind, got it working that way TopRatedPage.setDrawingCacheEnabled(true); TopRatedPage.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); TopRatedPage.layout(0, 0,
I am totally confused right now. Edit: Okay, nevermind. The Python socket as well
EDIT: Nevermind, found duplicate after searching for a completely unrelated topic (kinda serendipitous) Probably

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.