I currently have a sql statement that outputs data into an excel document. However, every time there is a cell that doesn't have data, it outputs NULL
into the cell. I was wondering if there was a way that I could replace NULL
with just a blank space? Someone suggested using coalesce to do this, however I haven't ever had the chance to use it so I will have to do some reading on it. Anyone have any other suggestions?
Null values are replaced with mean/median.
The steps are simple: Change the data type of the Date to a String (right-click on the field in the list of dimensions and Change Data Type) Right-click on the dimension again (once it's a string) and select Aliases. Set the Alias value for Null to be a space if you want it blank (or a “-“/dash/hyphen/minus/etc)
Use IFNULL or COALESCE() function in order to convert MySQL NULL to 0. Insert some records in the table using insert command.
In your select you can put an IsNull/IfNull round the column. Not particularly efficient but does what you want.
MS SQL
Select IsNull(ColName, '') As ColName From TableName
MySQL
Select IfNull(ColName, '') As ColName From TableName
IFNULL is an Oracle extension (adopted by many other platforms). The "standard" SQL function is coalesce():
SELECT COALESCE(columnName, ' ') AS ColumnName
FROM tableName;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With