473,400 Members | 2,163 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,400 software developers and data experts.

ignore -99 in query

26
Hi all,
This should be easy for oh so wise ones. So here it is I'm trying to add up some data in a query which is no big deal. But in this data base some N/A data is represented by -99. I would like to ignore all -99 when adding up this data.

Example
Expr1: [csbQ01]+[csbQ02]+[csbQ03]+[csbQ04]+[csbQ05]+[csbQ06]

Thanx for the help
May 13 '08 #1
6 1385
jeffstl
432 Expert 256MB
Hi all,
This should be easy for oh so wise ones. So here it is I'm trying to add up some data in a query which is no big deal. But in this data base some N/A data is represented by -99. I would like to ignore all -99 when adding up this data.

Example
Expr1: [csbQ01]+[csbQ02]+[csbQ03]+[csbQ04]+[csbQ05]+[csbQ06]

Thanx for the help

You need to have criteria that says WHERE csbQ04 <> -99

So in the criteria <> -99 or "-99" if its a string in the table.

Is this what you mean?

You could do an SQL View on your query and post the SQL here and I can modify it to exclude -99 if this doesnt help you.
May 13 '08 #2
BUmed
26
Yes this is what I want thank you. Here is the code and I have bold the areas that have -99
Expand|Select|Wrap|Line Numbers
  1. SELECT [Telephone Screen].famID, [Telephone Screen].infantID, [Telephone Screen].prbandID, [Telephone Screen].infID, [Telephone Screen].mID, [Telephone Screen].fID, [Telephone Screen].studygrp, [Telephone Screen].ifFName, [Telephone Screen].ifLName, [Telephone Screen].mFName, [Telephone Screen].mLName, [Telephone Screen].fFName, [Telephone Screen].fLName, [Telephone Screen].prFName, [Telephone Screen].prLName, [Telephone Screen].ifdob, [Telephone Screen].prdob, [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].*, [PB CSBS Caregiver Questionnaire Items 42-45 - 06M].*, [csbQ06]+[csbQ05] AS Expr2
  2. FROM ([Telephone Screen] LEFT JOIN [PB CSBS Caregiver Questionnaire Items 1-41 - 06M] ON [Telephone Screen].famID = [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].famID) LEFT JOIN [PB CSBS Caregiver Questionnaire Items 42-45 - 06M] ON [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].famID = [PB CSBS Caregiver Questionnaire Items 42-45 - 06M].famID
  3. ORDER BY [Telephone Screen].famID;
May 13 '08 #3
jeffstl
432 Expert 256MB
Hmm. Not sure if this will be right but try it out. The only reason it wouldnt work is if you need to specify the table that csbQ05 and csbQ06 come from like MyTable.csbQ05.

Expand|Select|Wrap|Line Numbers
  1. SELECT [Telephone Screen].famID, [Telephone Screen].infantID, [Telephone Screen].prbandID, [Telephone Screen].infID, [Telephone Screen].mID, [Telephone Screen].fID, [Telephone Screen].studygrp, [Telephone Screen].ifFName, [Telephone Screen].ifLName, [Telephone Screen].mFName, [Telephone Screen].mLName, [Telephone Screen].fFName, [Telephone Screen].fLName, [Telephone Screen].prFName, [Telephone Screen].prLName, [Telephone Screen].ifdob, [Telephone Screen].prdob, [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].*, [PB CSBS Caregiver Questionnaire Items 42-45 - 06M].*, [csbQ06]+[csbQ05] AS Expr2
  2. FROM ([Telephone Screen] LEFT JOIN [PB CSBS Caregiver Questionnaire Items 1-41 - 06M] ON [Telephone Screen].famID = [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].famID) LEFT JOIN [PB CSBS Caregiver Questionnaire Items 42-45 - 06M] ON [PB CSBS Caregiver Questionnaire Items 1-41 - 06M].famID = [PB CSBS Caregiver Questionnaire Items 42-45 - 06M].famID
  3. WHERE csbQ06 <> -99 AND csbQ05 <> -99 ORDER BY [Telephone Screen].famID;
  4.  
May 13 '08 #4
BUmed
26
Is there a was to add or null to this statement. Because some of the data is missing. Thanks for the help.
WHERE csbQ06 <> -99 AND csbQ05 <> -99
May 13 '08 #5
jeffstl
432 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1.  
  2. WHERE csbQ06 <> -99 AND csbQ05 <> -99 AND csbQ06 NOT NULL AND csbQ05 NOT NULL ORDER BY [Telephone Screen].famID;
  3.  
I believe that will do it.
May 13 '08 #6
BUmed
26
Thanks so much worked like a charm
May 13 '08 #7

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

Similar topics

9
by: hemal | last post by:
I came across a very strange situation at work. There is an order of magnitude difference in execution time for the following two queries (10 v/s ~130 msec): select count(*) from table_name...
4
by: Jon Westmore | last post by:
I'm using an ASP page to dynamically generate an XML document using a data source. I was thinking the concept would be similar to dynamically creating HTML but I'm running into an issue. Here is...
3
by: shorti | last post by:
I am looking for a way to insert into one table from another table but ignore duplicates (because the query will fail since the column I am inserting into is a unique index). RE: INSERT INTO...
10
by: molen malat | last post by:
i have a query with 4 fields, and a form based on it. i put another 4 textbox to get criteria to filter the query. the query runs normally when all the textbox have a value (not null) but when one or...
5
by: power2005 | last post by:
Hi Experts I'm having a problem with IIf statement and it's driving me crazy... i'm a total newbie and i've spent hours to make it work but to no avail... what I'm trying to do is to have a...
1
by: tembil | last post by:
Hi, here's the query that I used I need to know how to ignore errors when executing LOAD DATA infile 'myFile12_out.txt' INTO TABLE itc_db.tbl_address_out fields TERMINATED BY '|' lines...
1
by: coldude | last post by:
Hi, I have a data entry form that uses this ValidateTime code in VBA that checks of an entry may overlap in any way with any session already placed into the session_table. This is an inheritted...
18
by: sweeneye | last post by:
Hi, I'm basing a query on the variables used in a form. The database contains lots of problems, say with a computer and a tick box for the apropriate component like monitor, keyboard, mouse etc....
4
by: shodan | last post by:
Hi board, I'm using excel vba to drive my access database. Now I encountered the following problem: I have an update qry to update a table which has an index field. Because of this, I always...
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: 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
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.