Solved

How to handle N/A or Unknown Data

Posted on 2011-02-24
6
333 Views
Last Modified: 2012-05-11
Hi,

I have a field that takes numbers, a double type 100.45. However, the user says that sometimes the value is unknown. So, there are like two states for this field:

1. A number 0 to 1,000
2. Unknown or N/A value. Somebody has not measured it yet, so there is no value yet.

How can I design my table or the column to handle values like this and cover both states? I like to have a column with numbers only, and no chars in it to keep data integrity.

Any suggestions on how to handle this?

Thanks


0
Comment
Question by:gtrapp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 250 total points
ID: 34976047
Just allow nulls in the column definition.
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 125 total points
ID: 34976052
If possible, define your column as decimal(6,2) and insert N/A, Unknown values as NULL. If that is not possible and you have to have N/A and Unknown,
you have to define your column as varchar to hold string data.
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34976054

The best way is to use nulls for unassigned values
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 250 total points
ID: 34976071
If you allow nulls when you do a select you can handle the null using the ISNULL function like this :

Select ISNULL(mycolumn, 'N/A')
FROM mytable

This will return the column value if not null and return what is specified in the quotes if it is null.
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 125 total points
ID: 34978462
>> 1. A number 0 to 1,000
2. Unknown or N/A value.

Since you have stored character values in a numeric column, the best way without altering the table would be to use ISNUMERIC function as given below:

SELECT * FROM ur_table
WHERE ISNUMERIC(ur_column_name) = 1

If you are ok to change table structure along with data, then change your column datatype to INT and change those invalid characters as 0 or null..
0
 

Author Closing Comment

by:gtrapp
ID: 34980846
Thanks for the advice,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Concat multiple records into one line 3 42
Database maintenance 36 101
Replication failure 1 21
Convert VBA UDF to SQl SERVER UDF 4 49
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question