473,396 Members | 1,724 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.

Converting Access Query to SQL Server Query

Would anyone know how to convert this Access Query to SQL Server Query?

Format((([ResponsivenessQ1]+[ResponsivenessQ2]+[ResponsivenessQ3]+[ResponsivenessQ4])/(IIf([ResponsivenessQ1]>0,1,0)+IIf([ResponsivenessQ2]>0,1,0)+IIf([ResponsivenessQ3]>0,1,0)+IIf([ResponsivenessQ4]>0,1,0))),"Standard")

What this query is doing in Access is Averaging numbers that are not equal to 0. If the number is equal to 0, it should not be averaged in. The average is set to 2 decimal places.
Oct 9 '06 #1
1 2351
scripto
143 100+
try this

-----------optional just for testing -----------------------
declare @resq1 int,@resq2 int,@resq3 int,@resq4 int
set @resq1 = -1
set @resq2 = 2
set @resq3 = 0
set @resq4 = 5
----------------end optional-----------------------------------

select convert(decimal(10,2),(@resq1+@resq2+@resq3+@resq4 )/((case when @resq1 > 0 then 1 else 0 end)+
(case when @resq2 > 0 then 1 else 0 end)+
(case when @resq3 > 0 then 1 else 0 end)+
(case when @resq4 > 0 then 1 else 0 end)))
Oct 10 '06 #2

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

Similar topics

9
by: wiredog | last post by:
I am struggling rewriting my query from MS Access' IIF, Then to SQL Servers TSQL language. I am hoping some one can give me some guidance. I believe I have the first portion of the query correct...
5
by: Terry Bell | last post by:
I'm upsizing an Access database. Got the data converted, working on the front end, converting queries to views, but having trouble converting queries that use logical expressions like the...
4
by: dschl | last post by:
Hi, I'm converting an Access 2000 database to Sql Server and must be missing something obvious. Using the Import utility in Sql Server, the Access queries seem to get executed and the...
7
by: Dana Shields | last post by:
I am attempting to upsize from access to SQL Server. I'm trying to convert my queries to SQL Server views; however, I'm having a lot of difficulty with the syntax differences. For instance, a...
1
by: Stefan V. | last post by:
Hello! I am trying to convert a query written for SQL Server 2000 database tables, to a MS Access query. Here is what I have in SQL Server: SELECT t2.*, CASE WHEN t2.QType = '3' THEN...
2
by: Mark Flippin | last post by:
I'm converting the backend of an Access 2000 database to SQL Server 2000. The existing database has user and group security through a specific workgroup file. Under the "user and group...
2
by: ILCSP | last post by:
Hello, I have the following query in Access 2000 that I need to convert to SQL 2000: UPDATE tblShoes, tblBoxes SET tblShoes.Laces1 = Null WHERE (((tblShoes.ShoesID)=Int(.)) AND...
5
by: sparks | last post by:
We are slowly converting all of our older access 97 databases to 2003. One of them that has been running fine for 3 + years and has over 2000 records in is giving me a problem. It converted fine...
10
by: Anthony97 | last post by:
This is a problem I've been fighting through for the last month. I've been tasked with converting access 2007 queries to SQL Server 2005. I have been able to convert a number of queries associated...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.