IIF statement in query

C

cdolphin88

Hello,

I have the query below that I used an IIF statement to classified the
different band..

Is that possible to show me in only one column the different
classification? Because now it shows in 5 different column..

the query I'm using is like this:

SELECT band, IIF(band = 1, 'Very Low Priority'), IIF(band = 2, 'Low
Priority'), IIF(band = 3, 'Medium Priority'), IIF(band = 4, 'High
Priority'), IIF(band = 5, 'Very High Priority')
FROM Table1;

Cheers
 
G

Graham R Seach

SELECT band, IIf(band=1,"Very Low Priority", IIF(band=2,"Low Priority",
IIF(band=3,"Medium Priority", IIF(band=4,"High Priority","Very High
Priority")))) As Priority FROM Table1

....or...

SELECT band, Choose(band,"Very Low Priority", "Low Priority", "Medium
Priority", "High Priority","Very High Priority") As Priority FROM Table1

....or...

SELECT band, Switch(band=1,"Very Low Priority", band=2,"Low Priority",
band=3,"Medium Priority", band=4,"High Priority",band=5,"Very High
Priority") As Priority FROM Table1

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
D

Duane Hookom

Or don't use an expression at all. Create a small lookup table
tblPriorities
=============================
Band
Priority
With values like
1 Very Low Priority
2 Low Priority
...

You can add this table to your query and join the band fields.
 
G

Graham R Seach

Ahh, the simplest methods are always the best! :)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 

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