Sunday, 16 June 2019

SQL Tutorial : DRL / DQL - DISTINCT

DISTINCT OR UNIQUE:

*******************

REMOVES THE DUPLICATES AND DISPLAYS THE RESULT



DISTINCT KEYWORD HAS TO USED NEXT TO THE SELECT

KEY WORD



SELECT COMMISSION_PCT

FROM EMPLOYEES




SQL Tutorial : DRL / DQL - DISTINCT
Let's learn about next topic: DISTINCT

DISTINCT :
**********
- it will eliminate duplicate record and gives only the unique value
- can be used in conjunction
- we can use it with aggregates like AVG, COUNT, SUM, MAX, MIN etc


SELECT DISTINCT DEPARTMENT_ID
FROM EMPLOYEES

SELECT DISTINCT DEPARTMENT_ID,JOB_ID
FROM EMPLOYEES


Points to note:
- COMPUTATION INVOLVING NULL VALUES
- RETURNS A NULL VALUE:

ELECT EMPLOYEE_ID,LAST_NAME,
SALARY,COMMISSION_PCT,SALARY+SALARY*COMMISSION_PCT "MONTHLY COMP"
FROM EMPLOYEES

No comments:

Post a Comment