473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I am trying to convert a MS Access Query to a SQL query and I need help?

I am trying to convert a MS Access Query to a SQL query and I need help with some IIF Statements?

2 in particular that I've encountered problems with are:

Count(IIf([elphoursflag]=0 Or [elphoursflag]=2,IIf([envelopes].isitecode=[logsheets].isitecode,IIf([recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd([d],13,[dFirstPSYDate])),[zip]))))'AS wk2count,

AND

Format(Avg(IIf([elphoursflag]=0 Or [elphoursflag]=2,IIf([envelopes].isitecode=[logsheets].isitecode,IIf([recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd([d],13,[dFirstPSYDate])),[elphours])))),[0.0])AS wk2avg,

Any help that someone could offer would be greatly appreciated!
Thanks!
Mar 8 '07 #1
1 2299
After some more effort, I was able to get this working:
Count(case
when [elphoursflag]=0 Or [elphoursflag]=2 then
case
when [envelopes].isitecode=[logsheets].isitecode then
case
when [recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd([d],13,[dFirstPSYDate])) then
[zip]
end
end
end) AS wk2count,
Round(Avg(case
when [elphoursflag]=0 Or [elphoursflag]=2 then
case
when [envelopes].isitecode=[logsheets].isitecode then
case
when [recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd(day,13,[dFirstPSYDate])) then
elphours
end
end
end), 0.0) AS wk2avg,


I am trying to convert a MS Access Query to a SQL query and I need help with some IIF Statements?

2 in particular that I've encountered problems with are:

Count(IIf([elphoursflag]=0 Or [elphoursflag]=2,IIf([envelopes].isitecode=[logsheets].isitecode,IIf([recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd([d],13,[dFirstPSYDate])),[zip]))))'AS wk2count,

AND

Format(Avg(IIf([elphoursflag]=0 Or [elphoursflag]=2,IIf([envelopes].isitecode=[logsheets].isitecode,IIf([recdate] Between DateAdd([d],7,[dFirstPSYDate]) And (DateAdd([d],13,[dFirstPSYDate])),[elphours])))),[0.0])AS wk2avg,

Any help that someone could offer would be greatly appreciated!
Thanks!
Mar 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Guy | last post by:
I got a big Access file (1 400 tables) to convert to SQL and I would like to be provided with some automated tools, except upsizing wizard and DTS, to convert it on my own. I got a lot of forms...
1
by: ian m via SQLMonster.com | last post by:
Hi, I currently have a ms access update query that runs perfectly well and quicly in access however I now need to add this query to convert this qeryu to oracles equivelant sql syntax and add it...
2
by: Bubba | last post by:
I know it's possible, just don't know how to do it. I have a spreadsheet that I imported into access. Two of the columns in the table have Hard Drive space values listed for example 2.45 GB and 453...
3
by: jerry.ranch | last post by:
I have a need to convert simple dates (i.e. 02/14/2005) to a number, do some math, and convert back to a date. (in a simple query). The math involves adding or substracting days, and days of the...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
4
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
0
by: sebastiany | last post by:
Hi, I currently have a MS Access select query (pretty lengthy) that runs fine in MS Access, however I now need to convert this query to Oracle's equivelant SQL syntax so that I can create a SQL...
2
by: TroutmansRegistrar | last post by:
I have a web programming task that has me stumped. I hope that one of you could give me some insight or might know someone who could guide me in the right direction. This is the final piece of the...
3
by: PGM | last post by:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Projname, ProjSpon As String Dim AppName, AppType, AppSupp, AppDesc As String...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.