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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:49:10+00:00 2026-06-01T07:49:10+00:00

I want to left join 2 tables. So all attributes of left table should

  • 0

I want to left join 2 tables.
So all attributes of left table should be shown in result table, no matter if it can join with other table or not.

When I do the follwing, I dont get the expected result

week_table:
 date       kw note
 ---------- -- ----
 2012-04-01  0 NULL
 2012-04-02  0 NULL

fact_table:
id number_of_application number_of_cluster number_of_jvm number_of_node number_of_was fk_wasversion fk_date    fk_domain fk_osname fk_osarch fk_osversion fk_stage
 -- --------------------- ----------------- ------------- -------------- ------------- ------------- ---------- --------- --------- --------- ------------ --------
  1                   114                 8            80             18            18 6.0           2012-04-01 domain1   Linux     sparc     2            stage1
  2                   114                 8            80             18            18 6.0           2012-04-02 domain1   Linux     sparc     2            stage1
  3                   114                 8            80             18            18 6.0           2012-04-01 domain1   AIX       sparc     2            stage1
  4                   114                 8            80             18            18 6.0           2012-04-02 domain1   Solaris   sparc     2            stage1

When I do this:

select
  w.date,
  coalesce(sum(f.number_of_was), 0)
from 
  week_table w
    left join fact_table f on (w.date = f.fk_date) 
where f.fk_osname = "AIX" 
group by w.date;

I only get :

 date       coalesce(sum(f.number_of_was), 0)
 ---------- ---------------------------------
 2012-04-01                                18

Expected:

date       coalesce(sum(f.number_of_was), 0)
---------- --------------------------------
2012-04-02                         18

Does someone know why?

Best Regards

  • 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-01T07:49:12+00:00Added an answer on June 1, 2026 at 7:49 am

    Move the criteria on the outer joined table from the WHERE clause to the ON clause:

    select
      w.date,
      coalesce(sum(f.number_of_was), 0)
    from 
      week_table w
        left join fact_table f on (w.date = f.fk_date and f.fk_osname = "AIX") 
    group by w.date;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This query does not work. I want all the results from a LEFT JOIN
I want to left join two tables. My problem is that the table from
I want to join two tables using JPQL : SELECT * FROM A LEFT
I have two tables which I want to join together using a left outer
I'm doing a left join on several tables. What I want to happen is
I am joining 2 tables -tbl1 and tbl2. Left join give all data from
I have two tables I want to join. I want all of the categories
I have 2 tables that I want to LEFT JOIN and filter the results
I want to be able to inner join two tables based on the result
I have multiple tables that I want to join to get a specific result.

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.