Introduction
Function AVG
Functions SUM, MAX, MIN
30. MAX and MIN
Revision

Instruction

Great. Okay, one final piece of information: you can also use DISTINCT with MIN or MAX to find the minimal or maximal value, respectively.

SELECT MAX(DISTINCT price)
FROM project;

What is the difference between MAX(price) and MAX(DISTINCT price)? Well, we hate to disillusion you, but there is none. :)

It's just an interesting fact about SQL that you can use DISTINCT with MIN or MAX.

Exercise

Check it out for yourself. Show four columns:

  • the maximal number of words in a project,
  • the maximal distinctive number of words,
  • the minimal number of words,
  • and the minimal distinctive number of words.

Console

Code editor

Result

TableConsole