Hi,
I have the following query which returns Yes or No if a Stage value is found in tblCommissionNew
What I need to do is rather than return Yes or No, return the Cost from tblCommissionNew.
tblCommissionNew is setup as follows
Currently an example output is :-
35235 / Yes / No / No / No / No / No
And what I need is :-
35235 / 13.95 / Null / Null / Null / Null / Null
I have tried :-
but this did not returned the required results
I have the following query which returns Yes or No if a Stage value is found in tblCommissionNew
Code:
SELECT Quote_ID
,Max(IIf(Val([Stage]) = 1, 'Yes', 'No')) AS Stage_1_Calc
,Max(IIf(Val([Stage]) = 2, 'Yes', 'No')) AS Stage_2_Calc
,Max(IIf(Val([Stage]) = 3, 'Yes', 'No')) AS Stage_3_Calc
,Max(IIf(Val([Stage]) = 4, 'Yes', 'No')) AS Stage_4_Calc
,Max(IIf(Val([Stage]) = 5, 'Yes', 'No')) AS Stage_5_Calc
,Max(IIf(Val([Stage]) = 6, 'Yes', 'No')) AS Stage_6_Calc
FROM tblCommissionNew
GROUP BY Quote_ID;
What I need to do is rather than return Yes or No, return the Cost from tblCommissionNew.
tblCommissionNew is setup as follows
- CommissionID
- Stage
- Cost
Currently an example output is :-
35235 / Yes / No / No / No / No / No
And what I need is :-
35235 / 13.95 / Null / Null / Null / Null / Null
I have tried :-
Code:
SELECT Quote_ID
,Max(IIf(Val([Stage]) = 1, [Cost], '')) AS Stage_1_Calc
,Max(IIf(Val([Stage]) = 2, [Cost], '')) AS Stage_2_Calc
,Max(IIf(Val([Stage]) = 3, [Cost], '')) AS Stage_3_Calc
,Max(IIf(Val([Stage]) = 4, [Cost], '')) AS Stage_4_Calc
,Max(IIf(Val([Stage]) = 5, [Cost], '')) AS Stage_5_Calc
,Max(IIf(Val([Stage]) = 6, [Cost], '')) AS Stage_6_Calc
FROM tblCommissionNew
GROUP BY Quote_ID;
but this did not returned the required results