Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Differences between UNIQUE and DISTINCT in select statements

Answers were Sorted based on User's Feedback



Differences between UNIQUE and DISTINCT in select statements..

Answer / kkparambath

SELECT DISTINCT Example

The "Persons" table:
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to select only the distinct values from the
column named "City" from the table above.

We use the following SELECT statement:
SELECT DISTINCT City FROM Persons

The result-set will look like this:
City
Sandnes
Stavanger

Is This Answer Correct ?    7 Yes 9 No

Differences between UNIQUE and DISTINCT in select statements..

Answer / chandrakant agrawal

Let us try one using :

select distinct dept_name
from departments;

What this query would return if dept_name column contains
NULL values.

Is This Answer Correct ?    3 Yes 11 No

Differences between UNIQUE and DISTINCT in select statements..

Answer / satish parashar

After applying the unique clause all the value of column
will be sorted, But in distinct clause it only remove the
duplicacy from the table,not sorted the column value.

Is This Answer Correct ?    6 Yes 15 No

Differences between UNIQUE and DISTINCT in select statements..

Answer / apparao akki

Hi all,

plz find the below executed report on the same.
------------------------------------------------------


SQL> select * from person;

PERSON_ID FIRST_NAME LAST_NAME
TITLE_1 TITLE_2 SOCS
---------- --------------------- -------------------------
---------- ---------- -----------
9 ssss rrrrr
tttt gggg 67778-3
1 THUUTHTUT lofstrom
ba null 4940-343
1 ffsdf fsdfsd
fdsfsd fsdf 5454
1 THUUTHTUT lofstrom
ba null 4940-343
1 THUUTHTUT lofstrom
ba null 4940-343
1 appa akki
s/w btech 3i
2 rao
s/w kmm 3i
4 bunny neel
lkg ukg home

8 rows selected.

SQL> select unique(person_id),last_name from person;

PERSON_ID LAST_NAME
---------- -------------------------
2
1 lofstrom
4 neel
1 fsdfsd
9 rrrrr
1 akki

6 rows selected.

SQL> select distinct(person_id) from person;

PERSON_ID
----------
4
9
2
1

Is This Answer Correct ?    9 Yes 20 No

Differences between UNIQUE and DISTINCT in select statements..

Answer / vidya

unique allows null value but distinct does not consider
null value

Is This Answer Correct ?    2 Yes 44 No

Differences between UNIQUE and DISTINCT in select statements..

Answer / guest

UNIQUE and DISTINCT

Is This Answer Correct ?    32 Yes 100 No

Post New Answer

More SQL PLSQL Interview Questions

What is bind variable in pl sql?

0 Answers  


What are the two characteristics of a primary key?

0 Answers  


What are views in sql?

0 Answers  


What is the use of %rowtype?

0 Answers  


Which function is used to return remainder in a division operator in sql?

0 Answers  


Explain the structure of pl/sql in brief.

0 Answers  


how many tables will create when we create table, what are they? : Sql dba

0 Answers  


Where the Pre_defined_exceptions are stored ?

2 Answers  


How do you create an update query?

0 Answers  


Delete the emps whose salaries are lowest sals of their own dept.

5 Answers  


When we give SELECT * FROM EMP; How does oracle respond?

24 Answers   Accenture, HCL, Infosys,


how will u find statistics of a database objects?

2 Answers   iFlex,


Categories