Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-11-09 : 09:03:04
|
| Lukmaan writes "Hello All, Im quite new to SQL Server. Can any one help me regarding the following query? This query is raising an error message " Syntax Error near the Key word NOT". But this query is working in MS Access. I need help. Please see the query below. Set rs3 = cn.Execute("select count(iif(dept NOT IN ('0106', '0107','0130'),itemno)) as Mainitems, count(iif(dept IN ('0106','0107','0130'),itemno)) as Accessories, sum(price) as TotalAmt from toprint where (invdate>'" & DTPicker1.Value & "' or invdate = '" & DTPicker1.Value & "') and (invdate <'" & DTPicker2.Value & "' or invdate = '" & DTPicker2.Value & "') and loc = '" & a & "' and dept like '01%'") Thanks in Advance." |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-11-09 : 09:48:28
|
| Your trying to use iif. You will need to replace it with a CASE statement. Look it up in books online. |
 |
|
|
|
|
|