UPPER()

SQL · String Functions

Theory

UPPER(string) returns the string with every letter converted to uppercase, leaving digits, spaces and symbols as they are. UPPER('jaipur') returns 'JAIPUR'. Like LOWER, it does not change stored data unless used in an UPDATE.

It is used to normalise codes and labels that are expected in capitals: department codes, country and state codes, PAN-style IDs, product SKUs. If the same department is stored as 'it', 'IT' and 'It', a GROUP BY dept treats them as three different groups in case-sensitive databases, while GROUP BY UPPER(dept) brings them together, as the diagram shows. UPPER is also used for case-insensitive comparison (UPPER(a) = UPPER(b)). It handles accented and other alphabets according to the database's character rules, so results for non-English text can vary slightly between systems.

Why we use it

Inconsistent capitalisation splits what should be one group into several and breaks lookups against code tables. UPPER gives every value one canonical form so grouping, joining and display are consistent.

When to use it

Use UPPER for codes and labels that should be all caps, or to normalise both sides of a comparison. For proper names that need 'Asha Rao' style, use INITCAP (where available). Fix the data at load time when you can, rather than in every query.

How it works

  1. Take the input string
  2. Read each character
  3. Is it a lowercase letter? Yes: Replace it with its uppercase form. No: Keep it unchanged.
  4. Repeat to the end of the string
  5. Return the uppercased copy

Syntax

UPPER(string)

Example

SELECT UPPER(department) FROM employees;

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