Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

IIF and Case is SQL through ASP

After reading multiple questions and answers in this forum I've tried a number of solutions to an error from SQL.  
"Incorrect syntax near '>'."

Through changing operator, I've determined it points to the >= in

case tblARInvoices.date when >= '01/12/04'

Prior to using a case expression, I was using IIF but read that this is not supported.  I changed to the CASE and got the same error message.

I'm missing something.

Any help is appreciated.

SQL = "SELECT tblARInvoices.[Invoice#], tblARInvoices.Date, " & _
"tblOEOrders.[Order#], tblCustomers.CustomerName, " & _
"tblInventory.[Part#], tblInventory.Description,  " & _
"tblARInvoiceDetail.SplitAmount AS Sale, " & _
"case tblARInvoices.date when >= '01/12/04' And <='02/29/2004' then '20%' else '10%') end AS Pct, " & _
"case tblARInvoices.date when >= '01/12/04' And " & _
" <='2/29/2004') then [Sale]*0.2 else [sale]*0.1 end AS Accrual, " & _
" case accrual when >5000 then 5000 else accrual AS Earned " & _

0
ckausen
Asked:
ckausen
1 Solution
 
etmendzCommented:
CASE may be used this way:

CASE WHEN tblARInvoices.date >= '01/12/04' THEN ...
...

Observe that tblARInvoices.date is placed after WHEN instead of after CASE. Rewrite your code so that you complete the condition expression inside the WHEN clause...

Have fun.

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now