Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I have two columns which values contains 0(ZERO) both columns are string.
Expression: col1/col2
datatype should be float or decimal and load into redshift table(numeric data type)
Note: col1 and col2 either or both contains 0 values col1 and col2.
How to achieve above scenario.
Thanks
shree
You need to use equals method to compare string variables, then you can use Float.parseFloat to convert both strings to Float before the division:
(row1.col2.equals("0")) ? 0 : Float.parseFloat(row1.col1) / Float.parseFloat(row1.col2)
@bshree88, did this help you? If so, thank's to mark you case as Solved (Kudos also accepted)