Help me on Expresssion in Query

B

Bart

I have a query with below output

Ref No Status Remarks1 Remarks2 Remarks3 Remarks4 Remarks5
1 Closed Yes
2 Closed No
3 Closed Yes No
4 Closed No Yes Yes

I want to have another column with name "OVERALL REMARKS" with condition
below:

If any of the Remarks from Remarks1 to Remarks5 has "NO" value, then the
OVERALL REMARKS should be "NO". How would i do this?

Below is my current SQL

SELECT Main.[Ref No], Main.Status, [Action Plan 1A].Remarks1, [Action Plan
2A].Remarks2, [Action Plan 3A].Remarks3, [Action Plan 4A].Remarks4, [Action
Plan 5A].Remarks5
FROM ((((Main LEFT JOIN [Action Plan 1A] ON Main.[Ref No] = [Action Plan
1A].[Ref No]) LEFT JOIN [Action Plan 2A] ON Main.[Ref No] = [Action Plan
2A].[Ref No]) LEFT JOIN [Action Plan 3A] ON Main.[Ref No] = [Action Plan
3A].[Ref No]) LEFT JOIN [Action Plan 4A] ON Main.[Ref No] = [Action Plan
4A].[Ref No]) LEFT JOIN [Action Plan 5A] ON Main.[Ref No] = [Action Plan
5A].[Ref No]
WHERE (((Main.Status)="Closed"));
 
R

RonaldoOneNil

SELECT Main.[Ref No], Main.Status, [Action Plan 1A].Remarks1, [Action Plan
2A].Remarks2, [Action Plan 3A].Remarks3, [Action Plan 4A].Remarks4, [Action
Plan 5A].Remarks5, IIf([Remarks1]="No" Or [Remarks2]="No" Or [Remarks3]="No"
Or [Remarks4]="No" Or [Remarks5]="No","No","Yes") AS [Overall Remarks]
FROM ((((Main LEFT JOIN [Action Plan 1A] ON Main.[Ref No] = [Action Plan
1A].[Ref No]) LEFT JOIN [Action Plan 2A] ON Main.[Ref No] = [Action Plan
2A].[Ref No]) LEFT JOIN [Action Plan 3A] ON Main.[Ref No] = [Action Plan
3A].[Ref No]) LEFT JOIN [Action Plan 4A] ON Main.[Ref No] = [Action Plan
4A].[Ref No]) LEFT JOIN [Action Plan 5A] ON Main.[Ref No] = [Action Plan
5A].[Ref No]
WHERE (((Main.Status)="Closed"));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top