0

I have a rounding length value by contract. I would like to round my data table by this value however I cannot find how to input it dynamically (ie changing 2 in the example below by 5). Is it possible?

Table trading.data18 structure idcontract integer close double

Table contracts structure idcontract integer rounding double

My static query so far

select ROUND(CAST(close AS numeric),2) from trading.data18 limit 10;

enter image description here

2
  • 1
    Can you share your table structures pls. Commented Dec 21, 2022 at 11:09
  • @Stefanov.sm I have added the request Commented Dec 21, 2022 at 11:24

1 Answer 1

1

You can use contracts.rounding as a second argument of round.

select round(d.close, c.rounding::integer)::numeric
from trading.data18 as d
join contracts as c using(idcontract);

using(idcontract) is a shorthand for on c.idcontract = d.idcontract

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.