Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

round to 2 digit in postgres

((((t."Open" + t.lag_start) - ((2)::numeric * (t."Open" - h.value))) * (100)::numeric) / t."Open") AS perprofit,

the result is  2.487582758758   I want only 2.49



  SELECT t."Date",
    t."Open",
    t.name,
    t."Low",
    t.chg,
    t.lag_start,
    ((t."Open" + t.lag_start) - ((2)::numeric * (t."Open" - h.value))) AS profit,
    ((((t."Open" + t.lag_start) - ((2)::numeric * (t."Open" - h.value))) * (100)::numeric) / t."Open") AS perprofit,
    h.value,
    h.value AS gap
   FROM ("chgView" t
   JOIN helpertable h ON ((((t."Open" - t."Low") - h.value) >= (0)::numeric)));

Open in new window



I try this one but it error


 SELECT t."Date",
    t."Open",
    t.name,
    t."Low",
    t.chg,
    t.lag_start,
    ((t."Open" + t.lag_start) - ((2)::numeric * (t."Open" - h.value))) AS profit,
    round(((((t."Open" + t.lag_start) - ((2)::numeric * (t."Open" - h.value))) * (100)::numeric) / t."Open").,2 )AS perprofit,
    h.value,
    h.value AS gap
   FROM ("chgView" t
   JOIN helpertable h ON ((((t."Open" - t."Low") - h.value) >= (0)::numeric)));

Open in new window

SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Because it's followed by another column selection ?