It’s summing everything for all rows.

and here is the query:

I’m wondering if the problem lies in my WHERE clause? I’m still very new to this and with a WHERE clause this big it can get screwy quick.
Thanks in advance!
Aaron
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It’s giving you the same numbers from each row because of how you have the
JOINs structured.SELECTthe plant from pinvJOINfrompinv->pfbased on DATE (not plant)JOINtoppfbased on the date inpf(not plant)JOINtoprcbased on the date inpf(not plant)JOINtodptbased ondepartment_number(not plant)JOINtoplsbased onpf(which again was linked to plant table by DATE) (not plant)WHEREclause based again on DATEYou need to link the production numbers directly to the plant to get data specific to the plant. I think you are basically aggregating here without a
GROUP BY. Any real insight will require you to post your table structure and relationships.