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

sql query wrong result

232 100+
Expand|Select|Wrap|Line Numbers
  1. select count(*) 
  2. from result 
  3. where  reslt<>"A"
why my access query counts null within "A" category
and resultant doesnt include null data. m very confused.
Kindly help me how to correct it.
thanks in advance
ACCESS 2007
WINDOW 7
Aug 13 '13 #1
5 1250
jimatqsi
1,271 Expert 1GB
Your question is not very clear. Best advice I can offer for now is to always wrap potential Nulls in NZ to avoid guessing what will happen with Nulls altogether.
Expand|Select|Wrap|Line Numbers
  1. Select count(*) from result where nz(reslt,"A")<>"A"
will avoid counting Nulls.
Expand|Select|Wrap|Line Numbers
  1. Select count(*) from result where nz(reslt,"")<>"A"
will include Nulls in the count

Jim
Aug 13 '13 #2
Rabbit
12,516 Expert Mod 8TB
You can't compare values to nulls because nulls have no values to compare. You must either specifically account for nulls using something like is null or you need to convert null values to something else using something like Nz.
Aug 13 '13 #3
kkshansid
232 100+
null is also not equal to "A" then why its wrong?
Aug 14 '13 #4
zmbd
5,501 Expert Mod 4TB
kkshansid

perhaps these two articles will help you understand:
> What is a Null value in Access? Access 2002
In Access, a Null value indicates missing data in a field. A field could contain a Null value because the information is not known, or because the field doesn't apply to the record. A Null value is not the same as a value of 0 (zero) or a zero-length string ("") because those values are defined - you know what they are.

Because a Null value is not defined, you do not have enough information about a Null value to compare it to any other value. For example, when you use expressions to specify criteria for a field in a query or an advanced filter, the results will not include Null values in that field. The following example demonstrates this and illustrates the difference between a Null value and a zero-length string:(...)
(I know, V2002; however, the information hasn't changed thru to 2010)
> Examples of expressions that check for null values (Access 2003)
(once again, the information hasn't changed thru to 2010)
Aug 14 '13 #5
Rabbit
12,516 Expert Mod 8TB
It's wrong to say null is not equal to "A".

Basically, you don't know that a null value is not equal to A. A null value is undefined, null could equal A, or it could equal B, or C, or D, etc. Null can be equal to anything which is why it has special functions to handle it.

Think of nulls as a container with something inside. You just don't know what's inside. If you said you wanted all the containers without a teddy bear inside, then you wouldn't get the container that has an unknown object inside because it could be a teddy bear.
Aug 14 '13 #6

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

Similar topics

13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
5
by: Krisnamourt Correia via SQLMonster.com | last post by:
I have one query that executes many times in a week. I created one Maintenances plan that Rebuild all index in my Database that has been executed at 23:40 Saturday until stop finished at Sunday. ...
3
by: Kangan | last post by:
Hi, Is there a way to display just the first five rows of the query stt result in DB2. I know that there is something called select Top 5 * from tablename in SQL Server 2000. Is there a wayaround,...
3
by: Peter | last post by:
Hello all, I have the following t-sql batch: create procedure stp_test ( @p_date1 as datetime = null, @p_date2 as datetime = null )
0
by: RayV | last post by:
I have a report based on a query that summarizes data by county that is giving me the wrong result. In the county header I have a text box with this control source =Avg() The data is Null...
2
by: Mayank1717 | last post by:
I am trying to change date into number format for that i am using formatnumber function but this function returning wrong result. for example : numeric value of 12/09/2007 is 39337 but it...
5
by: bmm | last post by:
I have a Store Procedure on a Sql Server 2000 Where I use the Table Hint "NoLock" on all selects. One of my clients (OleDbConnection from C#) doesn't get the same Result Set as the others. The...
2
by: HowHow | last post by:
Using Access 2000, normally query returns result horizontally. Is there any way to set the query to return result vertically? For example, my query shown the result as below: Heading ...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
3
by: canabatz | last post by:
im using paging on this query: i got this code that returning wrong results: (SELECT bid_price, count(*) as n from bidding_details where bid_id=$bid_id GROUP BY bid_price DESC HAVING n = 1 ) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
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
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.