{"id":6317,"date":"2013-09-07T00:00:50","date_gmt":"2013-09-07T00:00:50","guid":{"rendered":"http:\/\/craftydba.com\/?p=6317"},"modified":"2016-04-21T20:58:57","modified_gmt":"2016-04-21T20:58:57","slug":"math-functions-power","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=6317","title":{"rendered":"Math Functions &#8211; POWER()"},"content":{"rendered":"<p>I am going to remain on course with my series of short articles or tidbits on Transaction SQL <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms177516.aspx\">math functions<\/a>.  Most, if not all, of these functions have been in the product before the release of SQL Server 2005.  <\/p>\n<p>I am very proud of my daughter making the advance math class in sixth grade.  I am dedicating these blogs to her hard class work and love of the subject.<\/p>\n<p>I will be exploring the POWER() function today.  This function takes two expressions, a base B and a exponent\/power N, as input in either exact numeric or approximate numeric form.  This does not include the BIT data type.  If N is positive integer, the output of the function is the result of multiplying B times itself for a total of N times.<\/p>\n<p>There is a huge area of mathematics study called <a href=\"http:\/\/en.wikipedia.org\/wiki\/Exponentiation\">exponentiation<\/a>.  We will talk about other types of exponents in the future.<\/p>\n<p>The example below tests the <a href=\"http:\/\/technet.microsoft.com\/en-US\/library\/ms174276(v=sql.90).aspx\">POWER<\/a>() function with five different pairs of inputs: exact numbers, approximate numbers,  null base, null exponent, and null values for both arguments.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"power() - math functions\">\r\n--\r\n--  The POWER Function\r\n--\r\n\r\n-- Raise x to power of y\r\nSELECT \r\n    POWER(2, 4) AS EXACT_POWER, \r\n    POWER(2.500, 2.0) AS APROX_POWER, \r\n    POWER(NULL, NULL) AS UNK_TEST1,\r\n    POWER(2, NULL) AS UNK_TEST2,\r\n    POWER(NULL, 4) AS UNK_TEST3\r\nGO\r\n<\/span><\/pre>\n<\/p>\n<p>The output from the test is listed below.<\/p>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput: \r\n\r\nEXACT_POWER  APROX_POWER  UNK_TEST1  UNK_TEST2  UNK_TEST3\r\n------------ ------------ ---------- ---------- ----------\r\n16           6.250        NULL       NULL       NULL\r\n<\/span><\/pre>\n<\/p>\n<p>In short, the POWER() function if a fine replace of the <a href=\"http:\/\/technet.microsoft.com\/en-US\/library\/ms173569(v=sql.90).aspx\">SQUARE<\/a>() function if the exponent N, is the number 2.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am going to remain on course with my series of short articles or tidbits on Transaction SQL math functions. Most, if not all, of these functions have been in the product before the release of SQL Server 2005. I am very proud of my daughter making the advance math class in sixth grade. I am dedicating these blogs to her hard class work and love of the subject. I will be exploring the POWER() function today. This function takes two expressions, a base B and a exponent\/power N, as&hellip;<\/p>\n","protected":false},"author":1,"featured_media":5430,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[814],"tags":[31,15,913,918,29],"class_list":["post-6317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-very-short-articles","tag-database-developer","tag-john-f-miner-iii","tag-math-function","tag-sign","tag-tsql"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6317"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6317\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/5430"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}