I Have A Table Like This.
Cityno Cityname Mails
1 Bangalore 8km
2 Hsr Layout 20km
3 Mejistic 30km
4 Jayadeva 55km
5 Itpl 80km
6 Hebbal 115km
I Have Data Like This
I Want O/p Like This
Distance No.ofcity
0-50km 3
51-100km 2
101-150km 4
And So On
Answer Posted / js
SELECT R,COUNT(R) FROM
(
SELECT cityname,mail,
CASE WHEN SUBSTR(MAIL,1,INSTR(MAIL,'KM' )-1) BETWEEN 0 AND 50 THEN '0-50'
WHEN SUBSTR(MAIL,1,INSTR(MAIL,'KM' )-1) BETWEEN 51 AND 100 THEN '51-100'
ELSE '101-150' END R FROM CITY) GROUP BY R;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How many types of cursors supported in pl/sql?
What is primary key in db?
How to rename a column in the output of sql query?
How does a covering index work?
Mention what problem one might face while writing log information to a data-base table in pl/sql?
How can we store rows in PL/SQL using array?
What is the difference between function, procedure and package in pl/sql?
Is clustered index a primary key?
What are all the different normalization?
Explain the uses of control file.
Can you load data into multiple tables at once? : aql loader
how to fetch alternate records from a table? : Sql dba
If the application is running very slow? At what points you need to go about the database in order to improve the performance?
How do I make sql search faster?
What is sql*loader and what is it used for? : aql loader