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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:24:27+00:00 2026-05-26T21:24:27+00:00

So I have three tables I am trying to pull data from with the

  • 0

So I have three tables I am trying to pull data from with the following query:

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

The problem I’m having is that whenever there is a value that is not null from the nptcategories 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.

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?

Update

Okay so I found the offending line of code it is below:

left outer join nptcategories nptc on nptc.categoryid=tats.categorytypenumeric

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?

  • 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-26T21:24:28+00:00Added an answer on May 26, 2026 at 9:24 pm

    Okay, so after taking Wolf’s suggestion, i went in and ran the following line of code

        select categorytype, count(*) 
    from nptcategories 
    group by categorytype 
    having count(*) > 1;
    

    After running this, i found that somehow there were duplicates of records in this table so, this was fixed by removing the duplicates and setting the table to have unique ids. This was done by using the following script on the DB:

    alter table nptcategories add constraint nptcatidunq unique(categoryid)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL Left Join problem. I have three tables which I'm trying
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three tables. This query will write down the right answer (x-lines for
I am trying to pull multiple columns from 3 joined tables, but I want
I have been trying to build an SQL query to return matches between three
I have a timezone aware timestamptz field in PostgreSQL. When I pull data from
I'm simply trying to get data from two sql server db tables using ado.net
I'm trying to figure out how to pull different data scenarios from my table
I need to pull data from two tables: Neptune_FN_Analysis and Neptune_prem There will be

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.