November 3, 2010 at 8:47 am
I can't get the results to work correctly...
I get the 55 instead of 55.41
The SUM of Student is 665 and divide that by 12 it should be 55.41 (as done on a calculator)
How do I get this results then ?
November 3, 2010 at 8:53 am
It will be to do with data types. You need one of the operands to be non-integer to get this to work. Try this:
SELECT 665/12
SELECT CAST(665 AS MONEY)/12
..and you'll see what I mean.
November 3, 2010 at 9:14 am
Thanks, how do I CAST a column called [Student] so it will work?
November 3, 2010 at 9:42 am
Richard Warr (11/3/2010)
It will be to do with data types. You need one of the operands to be non-integer to get this to work. Try this:SELECT 665/12
SELECT CAST(665 AS MONEY)/12
..and you'll see what I mean.
MONEY is basically DECIMAL (19,4). SO i would suggest using DECIMAL (s,p) are per your requirement.. To learn more about DECIMAL, please refer Books Online or MSDN..
November 3, 2010 at 11:52 am
akhlaq768 (11/3/2010)
Thanks, how do I CAST a column called [Student] so it will work?
Replace the "665" with the column name.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply