Solved

Access query with IIF into SQL

Posted on 2001-08-14
3
301 Views
Last Modified: 2006-11-17
I have an existing query in Access that I need to get into SQL server. The query has an immediate if. SQL does not seem to use the IIF function. How might I write this in SQL?

SELECT MtgReg.MtgID, MtgReg.RegNum, HStatus.HStatusName, IIf(HStatus.HStatusName<>"Reserved",Null,Sum(([MtgHInv].[RmRate]*(DateDiff("d",[ADate],[DDate]))))) AS HotelCost FROM .....
0
Comment
Question by:susantrider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6384403
replace the IIF by CASE statements:

SELECT MtgReg.MtgID, MtgReg.RegNum, HStatus.HStatusName,
case when HStatus.HStatusName<>"Reserved" then Null
     else Sum(([MtgHInv].[RmRate]*(DateDiff("d",[ADate],[DDate])) ))
AS HotelCost FROM .....

Cheers
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6384405
further corrections:


SELECT MtgReg.MtgID, MtgReg.RegNum, HStatus.HStatusName,
case when HStatus.HStatusName<>'Reserved' then Null
    else Sum(([MtgHInv].[RmRate]*(DateDiff(day,[ADate],[DDate])) ))
AS HotelCost FROM .....

Cheers

0
 

Author Comment

by:susantrider
ID: 6384448
angellll, This worked for me. Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

707 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