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
Can we rollback truncate?
What is sql basics?
How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?
How do I view a sql database?
Write the order of precedence for validation of a column in a table? I. Done using database triggers. Ii. Done using integarity constraints
Is pl sql better than sql?
Does sap use sql?
What is attribute indicator in pl sql?
Why do we need databases?
Is a foreign key always unique?
What is cost in sql execution plan?
how to check myisam tables for errors? : Sql dba
What is the command used to fetch the first 5 characters of a string?
How many postgresql users are there, worldwide?
What's the difference between a primary key and a clustered index?