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
 "Power Of" in SQL?

Author  Topic 

matta0990
Starting Member

44 Posts

Posted - 2012-07-03 : 08:56:13
Is there a way i can do a 'Power Of' calculation in SQL? If so can i have an example please.

Thanks,
Matt

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-07-03 : 09:29:16
If you mean exponentation:

SELECT POWER(10,3) -- 1000

If you mean the root of a number in another number's base:

SELECT LOG(1000)/LOG(10) -- returns 3 (10^3)
SELECT LOG(1024)/LOG(2) -- returns 10 (2^10)
Go to Top of Page
   

- Advertisement -