మాడ్యూల్ 2 · 4లో పాఠం 2కోర్సులో 6/57~6 min
మాడ్యూల్ పాఠాలు (2/4)
DISTINCTతో ప్రత్యేక విలువలు
Sometimes a column contains repeated values and you only care about the
list of distinct values. The keyword DISTINCT placed right after
SELECT removes duplicates from the result:
SQL
SELECT DISTINCT <colonne>
FROM <tabella>
[WHERE <condizione>];Uniqueness is evaluated over the combination of all listed columns. If you list two columns, two rows are considered equal only when both values match.
Examples
SQL
-- Le città in cui abbiamo almeno un dipartimento:
SELECT DISTINCT city FROM departments;
-- Le coppie (dipartimento, città) presenti (qui ognuna unica):
SELECT DISTINCT department_id, hired_on
FROM employees;Try it
వ్యాయామం#sql.m2.l2.e1
ప్రయత్నాలు: 0లోడ్ అవుతోంది...
List the distinct department_id values present among employees (duplicates must disappear).
ఎడిటర్ లోడ్ అవుతోంది…
సూచనను చూపించు
Add DISTINCT right after SELECT to remove duplicates.
3 ప్రయత్నాల తర్వాత పరిష్కారం లభిస్తుంది
Review exercise
వ్యాయామం#sql.m2.l2.e2
ప్రయత్నాలు: 0లోడ్ అవుతోంది...
List the distinct (department_id, hired_on) pairs for employees hired from 2020 onwards.
ఎడిటర్ లోడ్ అవుతోంది…
సూచనను చూపించు
DISTINCT evaluates uniqueness over the combination of all listed columns.
3 ప్రయత్నాల తర్వాత పరిష్కారం లభిస్తుంది