Skip to main content
PHP Blog

Back to all posts

How to Select Two Max Functions In Oracle?

Published on
4 min read
How to Select Two Max Functions In Oracle? image

Best Oracle Database Tools to Buy in December 2025

1 Prism Oracle: Tap into Your Intuition with the Magic of Color

Prism Oracle: Tap into Your Intuition with the Magic of Color

  • UNIQUE 45-CARD SET ENHANCES INTUITIVE READING EXPERIENCES.
  • COMPACT SIZE PERFECT FOR ON-THE-GO INSPIRATION AND GUIDANCE.
  • BEAUTIFULLY DESIGNED FOR A VISUALLY STRIKING ADDITION TO ANY DECK.
BUY & SAVE
$18.00 $21.95
Save 18%
Prism Oracle: Tap into Your Intuition with the Magic of Color
2 Work Your Light Oracle Cards: A 44-Card Deck and Guidebook

Work Your Light Oracle Cards: A 44-Card Deck and Guidebook

  • UNLOCK YOUR INTUITION WITH 44 INSPIRING ORACLE CARDS.
  • FIVE UNIQUE SUITS TO GUIDE YOUR JOURNEY OF SELF-DISCOVERY.
  • ILLUMINATE YOUR LIFE BY LIVING IN ALIGNMENT WITH YOUR TRUE SELF.
BUY & SAVE
$16.14 $21.99
Save 27%
Work Your Light Oracle Cards: A 44-Card Deck and Guidebook
3 Witch Tools Magic Oracle card: Fortune Teller Oracle cards for beginners, Uncover the mysterious wisdom of witchcraft with the help of sacred tools or magical symbols, gain guidance and inspiration

Witch Tools Magic Oracle card: Fortune Teller Oracle cards for beginners, Uncover the mysterious wisdom of witchcraft with the help of sacred tools or magical symbols, gain guidance and inspiration

  • UNLOCK MYSTICAL WISDOM: 54 ENCHANTING ORACLE CARDS FOR SPIRITUAL GUIDANCE!
  • PERFECT FOR BEGINNERS: CONNECT WITH ANCIENT MAGIC AND AWAKEN INTUITION!
  • IDEAL GIFT CHOICE: BEAUTIFULLY PACKAGED FOR ANY SPIRITUAL ENTHUSIAST!
BUY & SAVE
$16.99
Witch Tools Magic Oracle card: Fortune Teller Oracle cards for beginners, Uncover the mysterious wisdom of witchcraft with the help of sacred tools or magical symbols, gain guidance and inspiration
4 Sacred Symbols Oracle Deck: For Divination and Meditation

Sacred Symbols Oracle Deck: For Divination and Meditation

BUY & SAVE
$21.79 $25.99
Save 16%
Sacred Symbols Oracle Deck: For Divination and Meditation
5 Energy Oracle Cards

Energy Oracle Cards

BUY & SAVE
$14.90 $25.99
Save 43%
Energy Oracle Cards
6 Wisdom of the Oracle Divination Cards: A 52-Card Oracle Deck for Love, Happiness, Spiritual Growth, and Living Your Pur pose

Wisdom of the Oracle Divination Cards: A 52-Card Oracle Deck for Love, Happiness, Spiritual Growth, and Living Your Pur pose

  • IGNITE INTUITION WITH VIBRANT RED CARDS FOR DEEPER CONNECTIONS.

  • DURABLE, HIGH-QUALITY 52-CARD DECK FOR EFFORTLESS EXPLORATION.

  • INCLUDES 204-PAGE GUIDEBOOK FOR INSIGHTS FOR ALL SKILL LEVELS.

BUY & SAVE
$15.29 $23.99
Save 36%
Wisdom of the Oracle Divination Cards: A 52-Card Oracle Deck for Love, Happiness, Spiritual Growth, and Living Your Pur pose
7 78 Lythra Tarot Card Set, Tarot Oracle Cards for Beginners, Spiritual Tools for Intuition, Emotional Insight and Inner Wisdom, Suitable for Beginners and Advanced Readers

78 Lythra Tarot Card Set, Tarot Oracle Cards for Beginners, Spiritual Tools for Intuition, Emotional Insight and Inner Wisdom, Suitable for Beginners and Advanced Readers

  • CONNECT WITH YOUR INTUITION FOR PERSONAL GROWTH AND SELF-DISCOVERY.
  • ELEGANT ARTWORK MERGES NATURE AND MODERN SYMBOLISM FOR SERENITY.
  • SUITABLE FOR ALL LEVELS-INTUITIVE DESIGN ENSURES MEANINGFUL READINGS.
BUY & SAVE
$14.99
78 Lythra Tarot Card Set, Tarot Oracle Cards for Beginners, Spiritual Tools for Intuition, Emotional Insight and Inner Wisdom, Suitable for Beginners and Advanced Readers
8 The Healing Waters Oracle: A 44-Card Deck and Guidebook

The Healing Waters Oracle: A 44-Card Deck and Guidebook

BUY & SAVE
$17.43 $24.99
Save 30%
The Healing Waters Oracle: A 44-Card Deck and Guidebook
9 Angels and Ancestors Oracle Cards: A 55-Card Deck and Guidebook

Angels and Ancestors Oracle Cards: A 55-Card Deck and Guidebook

BUY & SAVE
$18.43 $21.99
Save 16%
Angels and Ancestors Oracle Cards: A 55-Card Deck and Guidebook
10 The Green Witch's Oracle Deck: Embrace the Wisdom and Insight of Natural Magic (Green Witch Witchcraft Series)

The Green Witch's Oracle Deck: Embrace the Wisdom and Insight of Natural Magic (Green Witch Witchcraft Series)

BUY & SAVE
$12.84 $19.99
Save 36%
The Green Witch's Oracle Deck: Embrace the Wisdom and Insight of Natural Magic (Green Witch Witchcraft Series)
+
ONE MORE?

To select the maximum value from two columns in Oracle, you can use the GREATEST function. The GREATEST function returns the maximum value among the specified expressions or columns.

Syntax:

SELECT GREATEST(column1, column2) AS max_value FROM table_name;

Example:

SELECT GREATEST(salary, bonus) AS max_pay FROM employees;

In the above example, the GREATEST function will compare the values of the salary and bonus columns for each row in the employees table and return the maximum value as max_pay.

Note that if any of the columns or expressions provided to the GREATEST function have a NULL value, the overall result will be NULL.

How to use a subquery with two max functions in Oracle?

To use a subquery with two MAX functions in Oracle, you can follow these steps:

  1. Start by writing the outer query that will use the subquery. This outer query will have the main query logic and will call the subquery.
  2. Inside the subquery, write the inner query that will calculate the maximum value for the first column. This can be done using the MAX() function and providing the column name as the argument.
  3. Use the result of the first subquery as the input for the second subquery. Write another subquery inside the outer query to calculate the maximum value for the second column.

Here's an example to demonstrate the usage:

SELECT col1, col2 FROM your_table WHERE (col1, col2) = ( SELECT MAX(col1), MAX(col2) FROM your_table );

In this example, "your_table" is the name of your table, and "col1" and "col2" are the column names for which you want to find the maximum values. The outer query retrieves the rows where the combination of col1 and col2 matches the maximum values obtained from the subquery.

You can adjust the table and column names according to your specific scenario.

What is the limit of using max function in Oracle?

In Oracle, there is no specific limit on using the MAX function. You can use the MAX function in various contexts, such as aggregating data in a SELECT statement or as a part of a larger query. However, the result returned by the MAX function depends on the data type of the input values. For example:

  • For numeric values, the MAX function will return the highest value.
  • For character or string values, the MAX function will return the value that comes last in alphabetical order.

It's worth noting that the MAX function may not perform efficiently if used on a large dataset, so it's essential to consider performance implications when using it extensively.

How to include other aggregate functions along with two max functions in Oracle?

To include other aggregate functions along with two max functions in Oracle, you can use the SELECT statement and the GROUP BY clause. Here is an example:

SELECT column1, MAX(column2), MAX(column3), COUNT(*) FROM table_name GROUP BY column1;

In this example, column1 is used as the grouping column, and MAX(column2) and MAX(column3) are the two max functions included. The COUNT(*) function is also included as another aggregate function.

Make sure to replace table_name with the actual name of your table, and column1, column2, and column3 with the actual column names you want to use.

What is the syntax for selecting two max functions with distinct values in Oracle?

The syntax for selecting two max functions with distinct values in Oracle can be achieved using subqueries. Here is an example:

SELECT MAX(col1) AS max_value1, MAX(col2) AS max_value2 FROM (SELECT DISTINCT col1, col2 FROM your_table) subquery_alias;

In this example, col1 and col2 are the columns from your table, and your_table is the name of your table. The subquery selects the distinct values of col1 and col2, and the outer query then calculates the maximum values for each column.