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
Which join is like inner join?
How do you rename a table in sql?
how are mysql timestamps seen to a user? : Sql dba
Can you select everything, but 1 or 2 fields, without writer's cramp?
What are the two types of periodical indexes?
Can we use threading in pl/sql?
Explain select statements in sql?
what are date and time functions in mysql? : Sql dba
What mean sql?
What is trigger in sql?
What is the maximum number of rows in sql table?
write an sql query to find names of employee start with 'a'? : Sql dba
What problem one might face while writing log information to a data-base table in pl/sql?
what are the different index configurations a table can have? : Sql dba
what is 'mysqlimport'? : Sql dba