Solved

IIF and Case is SQL through ASP

Posted on 2004-10-07
1
256 Views
Last Modified: 2010-05-19
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
Comment
Question by:ckausen
1 Comment
 
LVL 6

Accepted Solution

by:
etmendz earned 50 total points
ID: 12256777
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 168
Auto-indent certain lines in Notepad++ 10 111
Math Equation 23 105
maven disable workspace resolution 1 15
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question