Use of DISTINCT in SQL Query

Distinct operator in SQL Query

DISTINCT is used for fetch the distinct value of specific column in Oracle table.

Select distinct columnname, columnname from tablename;

I want to see distinct dept no in employee tables.

Select distinct deptno from employee;

You can pass two column to fetch distinct value of two columns:

select distinct first_name,last_name from employee;

Count the distinct number:
Count the distinct department from employee tables

select count(distinct deptno) from employees;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.