skip to Main Content

how i will put null values in place of dataset containing zeroes in place of missing values. can you help me with the solutuion?

in the new dataset the missing values were replaced by zeroes instead of null values. what function i should choose to put null values ?

2

Answers


  1. What is dataset?
    If it is a table with a column where values (some of them) are 0 and you want to change them to null then:

    Update your_table_name
    Set your_column_name = null
    Where your_column_name = 0;  -- or some other filter that you might need
    

    If dataset is result of some query then maybe something like…

    Select ID, COL_1, COL_2, COL_X,
           Case When column_with_zero_value = 0   -- and/or some other condition you might need
                Then Null 
           Else column_with_zero_value
           End as column_with_zero_value
    From your_table_name;
    

    … and if you want all null values in query result then…

    Select ID, COL_1, COL_2, COL_X, null  as your_column_name_with_null_values
    From your_table_name;
    
    Login or Signup to reply.
  2. What exactly does Generate mean here? you are looking for a Select statement that replaces if the value is zero to Null. If yes Check this.
    Use Case Statement in SQL.

    SELECT product_name,
    CASE
    WHEN price = 0 THEN NULL ELSE price
    END
    FROM products;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search