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 / janani

select '0-50' distance, count(*) No.ofcity from table
where mails between 0 and 50
union
select '51-100' distance, count(*) No.ofcity from table
where mails between 51 and 100
union
select '101-150' distance, count(*) No.ofcity from table
where mails between 101 and 150

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why cannot I use bind variables in ddl/scl statements in dynamic sql?

665


What is pragma in sql?

619


Can we insert in view in sql?

560


What are local and global Indexes and where they are useful.

924


How do you get column names only for a table (sql server)?

663






What is the most restrictive isolation level? : Transact sql

554


Does sap use sql?

513


What is partition in sql query?

515


Explain the components of sql?

587


How to move files from one directory to another in pl sql?

642


What are different joins used in sql?

548


What are views in sql?

543


what is table? : Sql dba

570


What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql

533


What does an inner join do?

557