Home » Oracle » Oracle Sql » Oracle sql: order by and distinct clause

Oracle sql: order by and distinct clause

In this section of Oracle sql,we will discuss about order by and distinct clause

Define a null value:

If a column in a table has no assigned value , then the column is said to be null for that row.

A null is a value that is unavailable,unassigned ,unknown. A null is not same as zero or space.
Zero is a number and space is a character

Some more points
1) Any datatype column can be null value
2) A primary key column is always not null
3)Any arithmetic expression containing the null, the result is null
Duplicate Rows and Distinct

The default display of select is all rows which may contains duplicate values

For examples

select * from emp;

It will return all the rows even some of them are duplicate

In some cases ,we dont want to see the duplicate rows,Sql has a clause to avoid it

Select distinct * from emp

The above query will not returns duplicate rows
How to display the table properties

Desc <table name >

It shows the table columnn, Null? and datatype

null? : If the column can have null value
datatype: it gives us the datatype of the column
Order by Clause

Order by clause sort the rows based on the column given. It could be asc or dsc . It comes last in the select statement

For example

select emp,salary from dept order by salary desc

It gives the output sorted by salary column in desc order ie. from max to low values

See also  Enterprise Manager 11g FMW Control in R12.2

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top