SQL Server makes good use of log10 and power functions

Source: Internet
Author: User
On the msdn machine, log10 and power functions are reversely related to each other. For example, 10 ^ log10 (n) = n. There is no problem when there is only one value. The result set is shown below .; With CAS (select number from master .. spt_values where number between 1 and 10 and type in ('P') Select power (10, sum (log10 (number ))) from C/* 3628800 */-- use a variable certificate to declare @ I intset @ I = 1; with CAS (select number from master .. spt_values where number between 1 and 10 and type in ('P ')) select @ I = @ I * number from cselect @ I/* 3628800 */-- the same as the correct go -- change the variable parameter number to declare @ t table (number INT) insert @ tselect 1 Union all select 2 Union allselect 4 select power (10, sum (log10 (number ))) from @ t/* 7 */declare @ I intset @ I = 1 select @ I = @ I * number from @ tselect @ I/* 8 */-- the result is incorrect. instead, more accurate. Select exp (sum (log (number) from @ t/* 8 */conclusion: Do not use the log10 logarithm when the result set is multiplied, you can also customize the number of letters.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.