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 February 2026

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

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

  • UNLOCK INSIGHTS WITH 45 BEAUTIFULLY ILLUSTRATED ORACLE CARDS.
  • PERFECTLY SIZED FOR EASY HANDLING AND MYSTICAL READINGS ANYWHERE.
  • ENHANCE YOUR INTUITION AND GUIDANCE WITH EVERY CARD DRAWN!
BUY & SAVE
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 OUR STUNNING 44-CARD ORACLE DECK!
  • ALIGN YOUR LIFE AND EMBRACE YOUR TRUE SELF EVERY DAY.
  • ILLUMINATE YOUR WORLD AND INSPIRE OTHERS WITH YOUR PRESENCE!
BUY & SAVE
Save 27%
Work Your Light Oracle Cards: A 44-Card Deck and Guidebook
3 Sacred Symbols Oracle Deck: For Divination and Meditation

Sacred Symbols Oracle Deck: For Divination and Meditation

BUY & SAVE
Save 16%
Sacred Symbols Oracle Deck: For Divination and Meditation
4 Energy Oracle Cards

Energy Oracle Cards

BUY & SAVE
Save 18%
Energy Oracle Cards
5 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
Save 7%
The Green Witch's Oracle Deck: Embrace the Wisdom and Insight of Natural Magic (Green Witch Witchcraft Series)
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

  • MESMERIZING RED DESIGN: CAPTIVATE USERS WITH VIBRANT ARTWORK FOR DEEPER CONNECTIONS.

  • PREMIUM QUALITY: DURABLE CARDSTOCK ENSURES SMOOTH SHUFFLING AND LASTING USE.

  • COMPREHENSIVE GUIDEBOOK: UNLOCK ORACLE WISDOM WITH 204 PAGES OF INSIGHTS.

BUY & SAVE
Save 39%
Wisdom of the Oracle Divination Cards: A 52-Card Oracle Deck for Love, Happiness, Spiritual Growth, and Living Your Pur pose
7 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

  • BEAUTIFULLY ILLUSTRATED CARDS: 54 ENCHANTING DESIGNS TO INSPIRE AND GUIDE.
  • VERSATILE USE: PERFECT FOR DAILY RITUALS, CREATIVITY, OR SPIRITUAL PRACTICES.
  • THOUGHTFUL GIFT IDEA: IDEAL FOR ANY OCCASION FOR SPIRITUAL ENTHUSIASTS.
BUY & SAVE
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
8 Angels and Ancestors Oracle Cards: A 55-Card Deck and Guidebook

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

BUY & SAVE
Save 16%
Angels and Ancestors Oracle Cards: A 55-Card Deck and Guidebook
9 Moonology Oracle Cards: A 44-Card Moon Astrology Oracle Deck and Guidebook

Moonology Oracle Cards: A 44-Card Moon Astrology Oracle Deck and Guidebook

  • ENJOY READING: ELEVATE YOUR EXPERIENCE WITH JOY IN EVERY PAGE!
  • PERFECT GIFT: DELIGHT BOOK LOVERS WITH A THOUGHTFUL SURPRISE!
  • SMART CHOICE: AN EXCELLENT PICK THAT ENHANCES ANY READING JOURNEY!
BUY & SAVE
Save 46%
Moonology Oracle Cards: A 44-Card Moon Astrology Oracle Deck and Guidebook
10 sishui 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

sishui 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

  • DISCOVER INNER WISDOM WITH EMPOWERING TAROT INSIGHTS FOR GROWTH.
  • ELEGANT, NATURE-INSPIRED DESIGN ENHANCES SPIRITUAL EXPLORATION.
  • IDEAL FOR ALL LEVELS, ENSURING MEANINGFUL EXPERIENCES FOR EVERYONE.
BUY & SAVE
sishui 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
+
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.