Thursday, February 20, 2014

Case Insensitive Sorting Example in Oracle11g


Step1: Create Employee table 
create table employee(id int, name varchar(20));
 
Step2: Insert values to Employee table
insert into employee values(1,'Ranga');
insert into employee values(2,'rAnga Reddy');
insert into employee values(3,'Raja');
insert into employee values(4,'raJa Reddy');
insert into employee values(5,'raja');
insert into employee values(6,'Reddy');
insert into employee values(7,'ranga');
 
Step3: Select the Employee values with out sorting
select * from employee;
------------------------------------------- 
ID NAME
1 Ranga
2 rAnga Reddy
3 Raja
4 raJa Reddy
5 raja
6 Reddy
7 ranga
 
Step4: Select the Employee values with sorting 
select * from employee order by name;
------------------------------------------- 
ID NAME
3 Raja
1 Ranga
6 Reddy
2 rAnga Reddy
4 raJa Reddy
7 ranga
5 raja

 
Step5: Select the Employee values with case insensitive sorting 
select * from employee order by upper(name);
------------------------------------------- 
ID NAME
5 raja
3 Raja
4 raJa Reddy
7 ranga
1 Ranga
2 rAnga Reddy
6 Reddy
 
Click here to Run and Test the above example in online.


0 comments: