Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Question - Criteria Difficulties

Status
Not open for further replies.

tbassngal

Programmer
Feb 18, 2003
74
US
I have a query that I am having problems with, please help:

SELECT R_Project_AllTaskDates.Program_Yr, R_Project_AllTaskDates.[Project Id], W_Data_SA_Download.[Pack Item #], W_Data_SA_Download.PS, W_Data_SA_Download.SA
FROM W_Data_SA_Download RIGHT JOIN R_Project_AllTaskDates ON W_Data_SA_Download.ProjectID = R_Project_AllTaskDates.[Project Id]
WITH OWNERACCESS OPTION;


What I'd like to do is limit the number of records based upon what is in the PS field. Bottom line is I am trying to add the SA field into this query. I originally had 69023 records in this query but by adding the SA field, I now have 1499541 (the difference is - there could be multiple SA entries for each Pack Item #). I only want to pull records that have an SA entry if PS = P or A for each Pack Item # (because I am reporting only on Project ID (not Pack Item #). Basically, we are reporting at the Project ID level (and never even show Pack Item # in the report) and each Project ID could have multiple Pack Item #'s with different SA entries where PS = A, P or S. I want to see the SA entry for the A or P - not for the S. See, there is only 1 P or A for each Pack Item #.

Do I write an expression to do this - any ideas or examples would really help. I am not all that familiar with expressions and I did not develop this database so any help you could provide would be extremely appreciated. I hope I didn't make this sound too confusing.
 
Hi

Code:
SELECT R.Program_Yr, R.[Project Id], W.[Pack Item #], W.PS, W.SA

FROM W_Data_SA_Download W RIGHT JOIN R_Project_AllTaskDates R ON W.ProjectID = R.[Project Id]
WITH OWNERACCESS OPTION

Where W.PS IN ('A','P');


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
I was afraid if I built my criteria to specify A or P that it would remove those records from my report but it couldn't because my joins are setup correctly. Thank you for your help! Everything is working now as it should.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top