G
Guest
I am trying to put an IF statement in my query. I need raw scores to be
adjusted to be between 0 and 1 if they aren't already. Here's what I want it
to do for 6 different fields:
If fieldrawscore > 1, then fieldrawscore = "1"
Else if fieldrawscore < 1, then fieldrawscore = "0"
Else fieldrawscore = fieldrawscore
End
I cannot figure out how to do this in my SQL expression (IIF isn't working
for me), and I am not savvy on VBA yet. (I'm not even sure how to incorporate
VBA within an existing query.)
I have an additional problem: my fieldrawscores that I want to use the IF on
are the result of another query that involves sums and other expressions.
Can I put the criteria in the same query that I build the expressions for the
fieldrawscores in? Or do I have to run a separate query just for the IF
criteria?
Here is the SQL for the query that contains the fieldrawscores that I need
to apply the criteria to:
SELECT BioRecon.brSampleDate,
(Sum([brTotalTaxa])-11)/25 AS [Total Taxa Raw Score],
(Sum([brEphemeropteraTaxa]))/5 AS [Ephemeroptera Taxa Raw Score],
(Sum([brTrichopteraTaxa]))/7 AS [Trichoptera Taxa Raw Score],
(Sum([brLongLivedTaxa]))/7 AS [Long Lived Taxa Raw Score],
(Sum([brClingerTaxa]))/8 AS [Clinger Taxa Raw Score],
(Sum([brSensitiveTaxa]))/9 AS [Sensitive Taxa Raw Score]
FROM BioRecon
INNER JOIN qryBioReconCountSummarybyDate ON
BioRecon.brSampleDate = qryBioReconCountSummarybyDate.brSampleDate
GROUP BY BioRecon.brSampleDate
ORDER BY BioRecon.brSampleDate;
Thank you!
adjusted to be between 0 and 1 if they aren't already. Here's what I want it
to do for 6 different fields:
If fieldrawscore > 1, then fieldrawscore = "1"
Else if fieldrawscore < 1, then fieldrawscore = "0"
Else fieldrawscore = fieldrawscore
End
I cannot figure out how to do this in my SQL expression (IIF isn't working
for me), and I am not savvy on VBA yet. (I'm not even sure how to incorporate
VBA within an existing query.)
I have an additional problem: my fieldrawscores that I want to use the IF on
are the result of another query that involves sums and other expressions.
Can I put the criteria in the same query that I build the expressions for the
fieldrawscores in? Or do I have to run a separate query just for the IF
criteria?
Here is the SQL for the query that contains the fieldrawscores that I need
to apply the criteria to:
SELECT BioRecon.brSampleDate,
(Sum([brTotalTaxa])-11)/25 AS [Total Taxa Raw Score],
(Sum([brEphemeropteraTaxa]))/5 AS [Ephemeroptera Taxa Raw Score],
(Sum([brTrichopteraTaxa]))/7 AS [Trichoptera Taxa Raw Score],
(Sum([brLongLivedTaxa]))/7 AS [Long Lived Taxa Raw Score],
(Sum([brClingerTaxa]))/8 AS [Clinger Taxa Raw Score],
(Sum([brSensitiveTaxa]))/9 AS [Sensitive Taxa Raw Score]
FROM BioRecon
INNER JOIN qryBioReconCountSummarybyDate ON
BioRecon.brSampleDate = qryBioReconCountSummarybyDate.brSampleDate
GROUP BY BioRecon.brSampleDate
ORDER BY BioRecon.brSampleDate;
Thank you!