Question : query to exclude multiple records


All

I have the below code that is currently in use counting SoE as "y".

What I would like to do is to modify this to only return those whose [Employment Term Description] is

NOT 'fixed term - 6 months' and NOT 'fixed term - 7 months' etc etc



SELECT DeptByArea.School, ActiveStatementDetails.[Department Description], Sum(IIf([Current SoE]="y",1,0)) AS YesCount, ActiveStatementDetails.[Employment Term Description]
FROM ActiveStatementDetails INNER JOIN (SOEYCount INNER JOIN DeptByArea ON SOEYCount.[Department Description] = DeptByArea.[Department Description]) ON ActiveStatementDetails.[Department Description] = SOEYCount.[Department Description]
GROUP BY DeptByArea.School, ActiveStatementDetails.[Department Description], ActiveStatementDetails.[Employment Term Description];


Whilst would be ideal to have a seperate query (which I will probably do) to only hold records with the above 'fixed term' not included.....how would I re write the code to exlcude these 'fixed term' not needed.

rgds

shaz0503

Answer : query to exclude multiple records

You may not like this, but this works :)
I think it is dead simple to understand, even for the MS Access engine.
Give you have varying terms like "Standard -.." I won't even try to parse it.

You need a * in "Standard -*" to mean "begins with"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
SELECT DeptByArea.School, ActiveStatementDetails.[Department Description], Sum(IIf([Current SoE]="y",1,0)) AS YesCount, ActiveStatementDetails.[Employment Term Description]
FROM ActiveStatementDetails INNER JOIN (SOEYCount INNER JOIN DeptByArea ON SOEYCount.[Department Description] = DeptByArea.[Department Description]) ON ActiveStatementDetails.[Department Description] = SOEYCount.[Department Description]
WHERE NOT (ActiveStatementDetails.[Employment Term Description] in (
	'fixed term - 1 months',
	'fixed term - 2 months',
	'fixed term - 3 months',
	'fixed term - 4 months',
	'fixed term - 5 months',
	'fixed term - 6 months',
	'fixed term - 7 months',
	'fixed term - 8 months',
	'fixed term - 9 months',
	'fixed term - 10 months',
	'fixed term - 11 months'))
AND NOT (ActiveStatementDetails.[Employment Term Description] LIKE 'Standard -*')
GROUP BY DeptByArea.School, ActiveStatementDetails.[Department Description], ActiveStatementDetails.[Employment Term Description];
Random Solutions  
 
programming4us programming4us