473,386 Members | 1,706 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,386 software developers and data experts.

create dummy variables

Hi, I have been trying to create a database where some questions are replied in a form in Access 2003. What I would like to achieve is to create a query that can convert these answers (options:Yes, No, N/A) to numbers (1,-1, 0) (although not all answers have exactly the same value, for example the values of another answer might be (Yes, No, N/A)=(1,-1,-1)) and then take the sum of the results of each record. This will allow me to make an evaluation of each record by using dummy variables. However, the SWITCH expression does not seem to work in this application. I would be grateful if you could make any suggestions.
Thanks in advance.
Sep 26 '07 #1
1 4696
nico5038
3,080 Expert 2GB
As the translation of the N/A can differ, I would start with an additional "steering" table with the QuestionID and the value for the three possibilities like:
QuestionID, TrueValue, FalseValue, NAValue

Next you can create a GroupBy query for the original table, JOINed by the QuestionID and the following IIF's:
Expand|Select|Wrap|Line Numbers
  1. select A.QuestionID, Sum(IIF(A.[Answer]=True,B.[TrueValue],IIF(A.[Answer]=False,B.[ValueFalse],B.[NAValue]))) As TotalQuestionValue from tblQuestion A, tblQuestionValues B WHERE A.QuestionID = B.QuestionID GroupBy A.QuestionID;
  2.  
Getting the idea ?

Nic;o)
Oct 5 '07 #2

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

Similar topics

4
by: Dave | last post by:
I have an application where I am providing the user the ability to select or create a folder on a domain, using SHBrowseForFolder. When the user selects/creates a folder on a remote computer, it...
1
by: js | last post by:
I am trying to create a primary key constraint on a view in the following statement. However, I got an error ORA-00907: missing right parenthesis. If the CONSTRAINT clause is removed, then the...
8
by: Steve Neill | last post by:
Can anyone suggest how to create an arbitrary object at runtime WITHOUT using the deprecated eval() function. The eval() method works ok (see below), but is not ideal. function Client() { }...
20
by: Gary Manigian | last post by:
I have 2 tables, one-to-many, that contain bills of material(BOMs): tblBOM: lngBOMID (PK) strAssemblyPartNo strDescription tblBOMDetail: lngBOMDetailID (PK) lngBOMID (FK)
5
by: s99999999s2003 | last post by:
hi i have a dir that contains directories with names and spaces in between example rootdir | ----> ABC DEF A | ---> BDD SD N I wanted to touch a file with the same name as the directories...
3
by: Miro | last post by:
I am teaching myself vb, and I was wondering if someone can check my code. -It works, but i was wondering if i was on the right track or if I should have done it differently. -Again - thanks in...
13
by: jtric | last post by:
Very new to XML/XSL, so please forgive me if this is an incredibly simple question. I've been pulling my hair out over this for several days now. I'm working on an internal application that takes...
3
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been...
35
by: erik gartz | last post by:
Hi. I'd like to be able to write a loop such as: for i in range(10): pass but without the i variable. The reason for this is I'm using pylint and it complains about the unused variable i. I can...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.