Hi everyone,
I am hoping for help on an IIF statement within a query that is not producing results expected. Analyzing a security table where I self-joined table and I need the results to display on one row per user. The scenario is looking at security values where access is granted using security type A and actions are granted with security type C AND D.
The IIF comes into the equation bc not all users have action rights C and D, but they all have A So when there is no C or D rights I need the IIF to just insert a value of 'N/A', but if the rights do exist, the results should return the update rights values in 4 columns. Here is my query:
Expected results would be:
USER // PROGRAM // SEC // RUNAPP // SEC // ADD // EDIT // DLETE //
SHAWN // OIL DRILL // A // YES // C // YES // YES // NO //
JAKE // ACCTS REC // A // YES // N/A // -- // -- // -- //
Results I receive instead is:
USER // PROGRAM // SEC // RUNAPP // SEC // ADD // EDIT // DLETE //
SHAWN // OIL DRILL // A // YES // C // YES // YES // NO //
JAKE // ACCTS REC // A // YES // A // // // //
The second 'A' value is incorrect. Any help is appreciated
I am hoping for help on an IIF statement within a query that is not producing results expected. Analyzing a security table where I self-joined table and I need the results to display on one row per user. The scenario is looking at security values where access is granted using security type A and actions are granted with security type C AND D.
The IIF comes into the equation bc not all users have action rights C and D, but they all have A So when there is no C or D rights I need the IIF to just insert a value of 'N/A', but if the rights do exist, the results should return the update rights values in 4 columns. Here is my query:
Code:
SELECT DISTINCT F.USER,, F.PROGRAM, F.SECTYPE, F.RUNAPP,
IIF(F1.SECTYPE IN ('C', 'D'), (V1.ADD, V1.EDIT, V1.DLETE), 'N/A')
FROM RIGHTS AS F INNER JOIN RIGHTS AS F1 ON (F.USER = F1.USER) AND (F.PROGRAM = F1.PROGRAM)
ORDER BY 1, 2;
Expected results would be:
USER // PROGRAM // SEC // RUNAPP // SEC // ADD // EDIT // DLETE //
SHAWN // OIL DRILL // A // YES // C // YES // YES // NO //
JAKE // ACCTS REC // A // YES // N/A // -- // -- // -- //
Results I receive instead is:
USER // PROGRAM // SEC // RUNAPP // SEC // ADD // EDIT // DLETE //
SHAWN // OIL DRILL // A // YES // C // YES // YES // NO //
JAKE // ACCTS REC // A // YES // A // // // //
The second 'A' value is incorrect. Any help is appreciated