I am practicing some examples in Oracle as i am new to it. I want to display the rows that are matched to First WHERE clause at beginning and last matched WHERE clause rows at last of below table.
CREATE table demo(id int, name varchar(50), city varchar(20), zip varchar(20));
insert into demo values(1,'oliver71','munich','85716');
insert into demo values(2,'markus71','munich','85716');
insert into demo values(3,'oliver81','stuttgart','70024');
insert into demo values(4,'peter82','hale','81978');
insert into demo values(5,'chinnarose71','rosenheim','80324');
insert into demo values(6,'guru11','berlin','81982');
insert into demo values(7,'sachin51','frankfurt','00712');
select name, city, zip from demo where zip like '%7%' OR city LIKE '%7%'
OR name LIKE '%7%';
How can i do that in Oracle. Any suggestions will be greatly appreciated.
There is no “WHEN” clause in your query. I assume you mean the parts of the WHERE clause.
To do this, you need a way of ordering the results. Here is one way using a subquery, which I think might be the clearest: