Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASTING SUMMARIZED FIELDS 2

Status
Not open for further replies.

cristi22

MIS
Aug 17, 2005
155
US
Hello all -

Please help with casting

I need to pass the field as decimal (9,2).
Both quantity & rate fields are defined as decimal (9,2)

Code:
sum ( cast (decimal(12,2), (rate * qty) ) as amount
is not working.... :(

thanks,
cristi
 
Does this work?

Code:
sum(CAST(rate as decimal(9,2))*INT(qty)) as amount

Ties Blom

 
Cristi,

You say that you want to pass the value as decimal 9,2 and that both columns are 9,2 but in the code you seem to be asking for a decimal 12,2 format. Which do you require?

Either way, I believe that something along the lines of the following should help:
Code:
SUM(CAST RATE * QTY AS DECIMAL(9,2)) AS AMOUNT

Marc
 
Oops, sorry, missed a set of brackets round the CAST!
Code:
SUM(CAST(RATE * QTY AS DECIMAL(9,2))) AS AMOUNT

Marc
 
thanks all for your help!
Code:
SUM(CAST(RATE * quantity AS DECIMAL(9,2))) AS AMOUNT
worked!
thanks cristi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top