seemingly incorrect syntax is working... it's killing me!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two different SELECT AS statements, back to back. my trimmed down
code looks like this, and where I put a comment beginning and ending with
***, this is not actually in my code

SELECT IIf([Age of employee] Between 0 And 29,"<30",IIf([Age of employee]
Between 30 And 34,"30-34",0)) AS [ageRange],
***This next IIf() begins a totally new statement, but it will not compile
if I place SELECT before the IIf***
IIf(
="Life", "w/o", IIf(
="AD&D", "w/",0)) AS [benefitType]

So this is going to confuse me forever... shouldn't I have another SELECT
there? because I'm dealing with [benefitType] and not [ageRange]​
 
SELECT is the keyword telling SQL what columns you want to show in your
query. You only have ONE SELECT per query (unless you are using a subquery
, which is another query).

Your second IIF statement is defining another column in the query.
 
Ohhh... ok. I have been reading other people's examples and trying to learn
the SQL syntax as I go (in my place of work, people don't believe that
someone should be reading a book... but if I'm sitting at my computer, they
assume it's productive.

John Spencer said:
SELECT is the keyword telling SQL what columns you want to show in your
query. You only have ONE SELECT per query (unless you are using a subquery
, which is another query).

Your second IIF statement is defining another column in the query.


Bigmike said:
I have two different SELECT AS statements, back to back. my trimmed down
code looks like this, and where I put a comment beginning and ending with
***, this is not actually in my code

SELECT IIf([Age of employee] Between 0 And 29,"<30",IIf([Age of employee]
Between 30 And 34,"30-34",0)) AS [ageRange],
***This next IIf() begins a totally new statement, but it will not compile
if I place SELECT before the IIf***
IIf(
="Life", "w/o", IIf(
="AD&D", "w/",0)) AS [benefitType]

So this is going to confuse me forever... shouldn't I have another SELECT
there? because I'm dealing with [benefitType] and not [ageRange]​

 
Back
Top