Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dave k wrote:
Is there a way to embed an if statement into a SQL select? SELECT F1, F2, IF(F11,F1*3,F1*2) FROM ATABLE Your use of F1 suggests you are querying Excel using MS Jet. Jet does not support the standard SQL CASE WHEN syntax, so try IIf (immediate if) e.g. SELECT F1, F2, IIF(F11,F1*3,F1*2) FROM ATABLE; For more complex case statements, you could use SWITCH e.g. SELECT F1, F2, SWITCH( F11 AND F1<=2, F1*3, F12 AND F1<=3, F1*4, 1=1, F1*2 ) FROM ATABLE; Jamie. -- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
embedding "ISERROR" function into an "IF" statement | Excel Worksheet Functions | |||
vba: How do I write a "For Each Statement" nested in a "With Statement"? | Excel Programming | |||
vba: How do I write a "For Each Statement" nested in a "With Statement"? | Excel Programming | |||
vba: How do I write a "For Each Statement" nested in a "With Statement"? | Excel Programming |