POWER()

SQL · Math Functions

Theory

POWER(base, exponent) raises a number to a power: POWER(2, 10) is 1024, POWER(10, 3) is 1000, POWER(9, 0.5) is 3 (a square root) and POWER(2, -1) is 0.5. It is the SQL way to write 'base multiplied by itself exponent times'.

Its main business use is growth. Compound interest is principal × (1 + rate)^years, so ₹1,00,000 at 8% for 5 years is ROUND(100000 * POWER(1.08, 5), 2) = ₹1,46,932.81. The same formula drives CAGR, inflation adjustment and exponential decay. POWER exists in PostgreSQL, MySQL (also as POW), SQL Server, Oracle, Snowflake and SQLite builds with math functions; PostgreSQL also has the ^ operator. One gotcha: in SQL Server the result takes the type of the base, so POWER(2, 0.5) returns 1 because 2 is an integer; write POWER(2.0, 0.5) to get 1.414. Large exponents can overflow, so keep values in a sensible range.

Why we use it

Growth compounds: interest, population, prices and user counts grow by a percentage of the previous value, not by a fixed amount. POWER computes such repeated multiplication in a single expression.

When to use it

Use POWER for compound interest, CAGR, squared distances and scoring formulas. For square roots SQRT is clearer. For simple squaring of a column, x * x is fine and avoids type surprises.

How it works

  1. Base and exponent, e.g. (1.08, 5)
  2. Is the exponent a fraction? Yes: Compute a root (0.5 = square root). No: Repeated multiplication.
  3. Does the result overflow? Yes: Error or Infinity — use DECIMAL. No: Continue.
  4. Return base^exponent

Syntax

POWER(base, exponent)

Example

SELECT POWER(2, 10);
-- 1024

Key points

SQL topics

Introduction to SQL

Querying Data

Sorting Rows

Limiting Rows

Filtering Rows

Joining Multiple Tables

Grouping Rows

SET Operators

Working with Tables

Modifying Data

Views & Triggers

Conditional Expressions

SQL Subqueries

Aggregate Functions

Window Functions

String Functions

Date Functions

Math Functions

Extra Concepts

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Master SQL from Zero to Pro

All SQL topics in one place. Click any topic in the sidebar — content opens right here without leaving the page.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice SQL Online Solve 150 SQL interview problems in a live editor with instant checking. Start practising →
Section {{ sec.num }}

{{ sec.label }}

SQL  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax
{{ current.syntax }}
Example
{{ current.example }}
▶ Try It Live — runs against a real sample database
{{ liveError }}
{{ col }}
{{ cell }}
Key Points — click to check off as you learn
  • {{ pt.mark }} {{ pt.text }}

Share this topic