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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding up to two decimal places

Status
Not open for further replies.

douggy

Technical User
Jan 18, 2001
78
GB
I have the following query:

SELECT a.AnimalID, a.RamID, a.AlleleA AS Allele, d .NumberDoses / 2 AS NumberDoses, d .StorageDate, a.AlleleA + '/' + a.Alleleb AS Genotype,
a.StorageTarget / 2 AS AlleleTarget
FROM dbo.VwArkAnimals a INNER JOIN
dbo.VwArkReportAnimalDoses d ON a.AnimalID = d .AnimalID
WHERE (a.AlleleA <> a.AlleleB) AND (a.AlleleA <> 'ARR') AND (a.AlleleB <> 'ARR')

I can not get the divided number to go to two dec places. ie when i put in ROUND(d .NumberDoses / 2,2) the resulting figure does not change.

What am I doing wrong?????

Any help appreciated. Thanks Mark
 
Thanks very much. However my results are still rounded down. They just now say 88.00 instead of 88. Should be 88.50.

Any further advice would be great otherwise thanks for looking at this.

Mark
 
Try:

[tt]CONVERT(decimal(8,2), d.NumberDoses/2.0)[/tt]

Roy-Vidar
 
Because your columns are integers, the division result will be an integer. You can change this by dividing by a decimal:

Code:
SELECT CAST(column / 2.0 AS decimal(8,2))

--James
 
Thanks all of you. Now sorted and working

Regards
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top