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

comparision of null values in sql

hi all how can we compare two null values in SQL...

for example.,

select ename,commission from emp e
where commission=(select commission from emp where ename=e.ename)

suppose commission of the employee is null it is not comparing the null value... it is omitting the record which has null value in commision....
this problem is too complex when we check for multiple queries......

request: i have also tried with commission is NULL but note that i want to compare the null values..
Oct 4 '07 #1
2 4746
debasisdas
8,127 Expert 4TB
Since null is not a value , u canst use any of the comparision operators on NULL.
Oct 4 '07 #2
gintsp
36
hi all how can we compare two null values in SQL...

for example.,

select ename,commission from emp e
where commission=(select commission from emp where ename=e.ename)

suppose commission of the employee is null it is not comparing the null value... it is omitting the record which has null value in commision....
this problem is too complex when we check for multiple queries......

request: i have also tried with commission is NULL but note that i want to compare the null values..
It is not clear what you want. If you wnat just rows where commision is null the write as follows:

select ename,commission from emp e
where commission IS NULL

If you want to compare two values with a requirement that if both values are null, then accept them as equivalent, then you can use
nvl(value1, <not_existing_value>) = nvl(value2, <not_existing_value>)
This compare has danger that probably sometimes <not_existing_value> will actually be in your data and the the absolutely secure way is:
where value1 = value2 or value1 is null and value 2 is null

Gints Plivna
http://www.gplivna.eu
Oct 4 '07 #3

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

Similar topics

26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
4
by: Ellen Manning | last post by:
Using SQL2000. I want to return the # of columns with non-null values. Here's my query so far: select case when Dx1 is not null then 0 else 1 end + case when Dx2 is not null then 0 else 1 end...
3
by: kd | last post by:
Hi All, How to perform case-insensitive comparision of strings? Would there be some kind of an indicator, which when set to true, would allow case-insenitive comparision of strings using...
13
by: Federico Balbi | last post by:
Hi, I was wondering if PGSQL has a function similar to binary_checksum() of MS SQL Server 2000. It is pretty handy when it comes to compare rows of data instead of having to write long boolean...
2
by: nirav.lulla | last post by:
I have been given the task to come up with Requirements, Comparision and Migration document from Shadow Direct to DB2 Connect. I am very new much to all this, but kind of know a little bit about...
3
by: abctech | last post by:
I have an Html page, user enters a Date (dd-mm-yyyy) here. There's a servlet connected in the backend for processing this submitted information, it must have a method to compare this entered date...
35
by: user34 | last post by:
(Sorry if this gets posted twice) Hi all. I am trying to learn C.As a simple exercise i tried to write a code which would compare two strings using pointers. However i am not getting the correct...
15
by: info | last post by:
Hi, I need this behaviour: 1 + null = 1 I have a (dynamic) set of many columns containing decimals that I want to add as follows: if all columns are null the result should be null if not all...
2
by: sgxbytes | last post by:
Hi, I have two strings with values say like String s1 ="hello,test,from,one,party"; String s2 = "into,bytes,hello,to"; i need to compare s1 values with s2 values if exists i need to return...
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
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.