Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Display Calculation

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-02-10 : 15:29:39
I have the following code. How can I modify it so it displays the value of what it will put in the tot_sls_amt? I do not want to update any tables.

begin
update oeordhdr_sql
SET tot_sls_amt = (select FLOOR(A.SumExtUnitPrice*100)/100 from(selecT ord_type,Ord_no,sum((UNIT_PRICE*QTY_TO_SHIP)-((unit_price * qty_to_ship)*(DISCOUNT_PCT*.01)))
as SumExtUnitPrice from oeordlin_sql
group by ord_type,ord_no)A
where A.ord_type = oeordhdr_sql.ord_type and A.ord_no = oeordhdr_sql.ord_no)
from oeordlin_sql join oeordhdr_sql on
oeordlin_sql.ord_type = oeordhdr_sql.ord_type and oeordlin_sql.ord_no = oeordhdr_sql.ord_no
where oeordhdr_sql.ord_type <>'C' and oeordlin_sql.line_no = 9999 and isnull(oeordlin_sql.item_desc_2,' ')<>'CHANGE' AND OEORDLIN_SQL.ITEM_NO = 'RBATE'
END

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-02-10 : 15:43:46
Or how would I round the result for tot_sls_amt??
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 22:57:08
do you meant this?


select FLOOR(A.SumExtUnitPrice*100)/100
from oeordhdr_sql
join oeordlin_sql
on
oeordlin_sql.ord_type = oeordhdr_sql.ord_type and oeordlin_sql.ord_no = oeordhdr_sql.ord_no
join
(selecT ord_type,Ord_no,sum((UNIT_PRICE*QTY_TO_SHIP)-((unit_price * qty_to_ship)*(DISCOUNT_PCT*.01)))
as SumExtUnitPrice
from oeordlin_sql
group by ord_type,ord_no)A
on A.ord_type = oeordhdr_sql.ord_type and A.ord_no = oeordhdr_sql.ord_no
where oeordhdr_sql.ord_type <>'C' and oeordlin_sql.line_no = 9999 and isnull(oeordlin_sql.item_desc_2,' ')<>'CHANGE' AND OEORDLIN_SQL.ITEM_NO = 'RBATE'

Go to Top of Page
   

- Advertisement -