Solved

IIF and Case is SQL through ASP

Posted on 2004-10-07
1
227 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresIncreasing challenge 10 57
recursion example 16 68
Windows Service to Receive TCP Packets 4 33
SUM 2 INTEGER ARRAYS INTO 1 10 57
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now