?
Solved

How to handle N/A or Unknown Data

Posted on 2011-02-24
6
Medium Priority
?
336 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 1000 total points
ID: 34976047
Just allow nulls in the column definition.
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 500 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 1000 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 500 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this article, we’ll look at how to deploy ProxySQL.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

764 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