I’m building a file, using SSMS, that will be an input to a machine learning program. The output file will be the result of a query of several tables in a SQL Server 2008 R2 Express DB.
The query results in NULL values for some of the cells. Currently I’m using the ISNULL() function to insert '0.00' when there is a NULL value but this is just a temporary measure as some values are actually '0.00' and this skews the calculation.
What raw data would look like:
id surveyResponseRate personResponseRate
001 .068 .15
002 0.00 NULL
003 .014 .03
004 NULL .20
005 .068 0.00
... ... ...
What current process creates:
id surveyResponseRate personResponseRate
001 .068 .15
002 0.00 0.00
003 .014 .03
004 0.00 .20
005 .068 0.00
... ... ...
I’m curious if there’s a way to create a binary column that is 0 if the value is actually 0.00 and 1 if it’s actually 0.00 due a NULL value.
What I’d like to see:
id surveyResponseRate personResponseRate survRRNA perRRNA
001 .068 .15 0 0
002 0.00 0.00 0 1
003 .014 .03 0 0
004 0.00 .20 1 0
005 .068 0.00 0 0
... ... ... ... ...
Any suggestions for how to do this?
Just add expressions for the new columns to the SELECT clause like this: