I have a table named c_price
and have a column value like below in PostgreSQL.
st_price 100.25 102.25
Now need a query for below result.
st_price | p1 | p2 ----------+-----+---- 100.25 | 100 | 25 102.26 | 102 | 26
Advertisement
Answer
trunc()
and mod()
may be used
select trunc(123.67) as dollars, trunc(mod(123.67*100,100)) as centsdollars | cents ------: | ----: 123 | 67
db<>fiddle here