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 / prativa mishra

select range distance,count(range) no_of_city
from
(SELECT cityname,mails,
CASE WHEN MAILS BETWEEN 0 AND 50 THEN '0-50'
WHEN MAILS BETWEEN 51 AND 100 THEN '51-100'
ELSE '101-150'
END RANGE
FROM CITY1)
group by range

Is This Answer Correct ?    20 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are all different types of collation sensitivity?

523


How can you tell the difference between an index and a view?

489


How to look at the current sql*plus system settings?

604


What is %type in sql?

510


What is PL/SQL Records?

626






What does 0 mean in sql?

526


What is the difference between joins?

534


how to get a list of columns in an existing table? : Sql dba

540


Advantages and disadvantages of stored procedure?

578


What is application trigger?

539


How much does a sql dba make? : SQL DBA

506


what are the different type of sql's statements ? : Sql dba

520


What is a clob in sql?

565


What is set transaction?

580


What is a table partition?

591