Sql-Keywords (distinct , order by) and where clause
Distinct Keyword
The DISTINCT keyword is used to return only distinct (unique) column values.
Sql tables often contains many duplicate values in columns and sometimes you only want to list the unique(distinct) values.
sample table :
to view on distinct column value following distinct command to execute
Select distinct empname from k4coding_emp
The ORDER BY keyword is used to sort the output in ascending or descending order.
ORDER BY Syntax
SELECT col1, col2,col3, ...
FROM tablename
ORDER BY col1, col2, ... ASC|DESC;
The ORDER BY keyword sorts the records in ascending order by default.
Select * from k4coding_emp order by empname
To sort the records in descending order, use the DESC keyword.
Select * from k4coding_emp order by empname desc





Comments
Post a Comment