Consider we are having following data in the table:
Select * from
and following is the result we are looking for:
So, how to do this?
We can achieve the above result by using REPLACE and TRIM functionality
Below is the query which would produce the above result:
Select replace(ltrim(replace(numcol,'0',' ')),' ' ,'0') from
So ,if you see:
a) We are replacing '0' with space by using Replace function
b) Then we are using LTRIM function as it would only Left trim the spaces from Left side
c) Then we are again replacing the spaces with Zero's , so this would bring back the zero anywhere already present.
Hope you would have liked this scenario.