Avatar of Trent Adams
Trent Adams asked on

SQL Query Syntax - Certain Rows Being Returned Multiple Times

I have an SQL store procedure that is being crazy for lack of better words. I doesn't seem to matter how I structure the joins, certain rows are being repeated a couple hundred times. Originally the stored procedure utilized all LEFT JOIN, however, I've been attempting to get this working by using a mixture of INNER and LEFT JOIN. Entries that are listed as HOURS will and an IndID, Expenses will have an IndID of -1.  The repeated issue you will observe the 425508 TimeCardID repeating.Please find attached the SP and screenshot.spr_payroll.txtScreen Capture
SQL

Avatar of undefined
Last Comment
Trent Adams

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
PortletPaul

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
PortletPaul

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Trent Adams

You were absolutely correct. A co-worker of mine also suggested to pick a claim and add joins 1-by-1 until I find the error. Which when I took another look at these joins when performing the 1-by-1 I realized that someone other than myself had joined a table alias on itself which was the cause of the issue. Thank you for your assistance.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23