Ok,I didn't elaborate enough:select casewhen coalesce(prc,0)=0 and coalesce(reg_prc,0)=0 and coalesce(cost,0)=0then NULLwhen coalesce(prc,0)=0 and coalesce(reg_prc,0)<>0 and coalesce(cost,0)<>0then cast(-((reg_prc-cost)/cost)as numeric)when coalesce (prc,0)<>0 and coalesce(cost,0)<>0then cast((((prc-cost)/cost)*100) as numeric)endas pct, casewhen coalesce(prc,0)=0 and coalesce(reg_prc,0)=0 and coalesce(cost,0)=0then NULLwhen coalesce(prc,0)=0 and coalesce(reg_prc,0)<>0 and coalesce(cost,0)<>0then cast(-((reg_prc-cost))as numeric)when coalesce (prc,0)<>0 and coalesce(cost,0)<>0then((prc-cost))endas profit_amt,ps_tkt_hist_lin.cost,tkt_no,ps_tkt_hist_lin.item_no, im_item.categ_codfrom ps_tkt_hist_linjoin im_itemon ps_tkt_hist_lin.item_no=im_item.item_noand im_item.item_no<>'NOTE'and im_item.categ_cod<>'WALAB'and im_item.categ_cod<>'RELAB'
This is the current code. This line:then cast(-((reg_prc-cost)/cost)as numeric)
will return -1.00000, but if I multiply it by 100 then I get the ACTUAL calculation, say 149 or something rather than 100, for the percentage. It is the negative amounts that aren't calculating right..There's never enough time to type code right, but always enough time for a hotfix...