dbms_random.value() in Snowflake - Oracle to snowflake conversion
Below is the oracle sql query that I got to convert to snowflake. In here, i am blocked in creating dbms_random.value() in snowflake
select emp_id, emp_name, emp_mob,
(case when dbms_random.value() >= 0.85 then 'Y' else 'N' end) as tag
from eds_dwg.employee_data
Can someone help me on this?
Thanks
You can use Snowflake Data generation functions: https://docs.snowflake.com/en/sql-reference/functions-data-generation.html
NORMAL() returns a floating point number with a specified mean and standard deviation. Something like this with correct adaptions of the parameters could to the trick: https://docs.snowflake.com/en/sql-reference/functions/normal.html
An alternative can be using UNIFORM(): https://docs.snowflake.com/en/sql-reference/functions/uniform.html
Example from docs to generate a value between 0 and 1:
select uniform(0::float, 1::float, random()) from table(generator(rowcount => 5));