ماڈیول 2 · سبق 2 از 4کورس میں 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 کوششوں کے بعد حل دستیاب ہے۔