November 25, 2003 at 12:42 pm
i have two numbers 999 and 888.But I want to muliply them as 900 and 800 .
Like that i want to do for other numbers
345*234->300*200
567*345->500*300.
Is there any function to achieve this.
Thanks
November 25, 2003 at 12:54 pm
declare @MyNumbers table (a int not null, b int not null)
insert into @MyNumbers select 345,234
insert into @MyNumbers select 567,345
select round(a,-2,0)*round(b,-2,0) from @MyNumbers
November 25, 2003 at 1:29 pm
Sorry; duplicate post. "Delete reply" still nonfunctional.
Edited by - Jonathan on 11/25/2003 1:44:33 PM
--Jonathan
November 25, 2003 at 1:37 pm
As you're wanting to truncate rather than round, I think cmore means:
SELECT ROUND(1,-2,1)*ROUND(b,-2,1)
If the vales are an integer data type, you could also just do something like this:
SELECT (a/100)*(b/100)*10000
--Jonathan
--Jonathan
November 25, 2003 at 1:55 pm
quote:
As you're wanting to truncate rather than round, I think cmore means:
SELECT ROUND(1,-2,1)*ROUND(b,-2,1)If the vales are an integer data type, you could also just do something like this:
SELECT (a/100)*(b/100)*10000--Jonathan
Oops. Yes thanks for catching that Jonathan.
November 26, 2003 at 12:42 am
Just curious, why?
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 26, 2003 at 2:38 am
for two integers @i & @j-2
the following should work
( looks like a slight overkill I know! )
select POWER(10,FLOOR(LOG10(@i)))*(FLOOR(@i)/POWER(10,FLOOR(LOG10(@i))))
*
POWER(10,FLOOR(LOG10(@j)))*(FLOOR(@j)/POWER(10,FLOOR(LOG10(@j))))
The advantage is that you don't have to worry about the precision of the integers - it'll work for 9 , 99 , 999, 9999 etc.
Regards
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply