Note that there are some explanatory texts on larger screens.

plurals
  1. POusing multiple left outer joins pl/sql
    text
    copied!<p>So I have three tables I am trying to pull data from with the following query:</p> <pre><code>select tats.machine_interval_id as machine_interval_id, tats.interval_type as interval_type, tats.interval_category as interval_category, ops.opstatemnemonic as operational_state, nptc.categorytype as idle_category, tats.interval_duration as interval_duration from temp_agg_time_summary tats left outer join operationalstates ops on ops.opstateid=tats.operationalstatenumeric left outer join nptcategories nptc on nptc.categoryid=tats.categorytypenumeric </code></pre> <p>The problem I'm having is that whenever there is a value that is not null from the <code>nptcategories</code> table, it double the record which in turns throws off any calculations I have later in my packages. I believe the problem has to do with having more than one left outer join in the query. My question may see fairly simple, but I'm new to PL/SQL so bear with me. </p> <p>What I want to know is how can I use multiple left outer joins in a query with out having this problem occur? What would be a better way to structure this query? </p> <p><strong>Update</strong></p> <p>Okay so I found the offending line of code it is below:</p> <pre><code>left outer join nptcategories nptc on nptc.categoryid=tats.categorytypenumeric </code></pre> <p>Also when using distinct, it removes all of the duplicate records, but will using this cause any problems I am unaware of? Should I focus more on figuring out why the join above does not work properly, or is the distinct good enough? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload