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

What is a recursive join sql?

597


What is the difference between partition and index?

485


What is the difference between sql and t sql?

538


Is left join inner or outer by default?

526


What is pl/sql table? Why it is used?

566






What is the difference between sql and mysql?

560


Which data type is a composite type?

534


What is a temporal table?

497


how to implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql dba

550


How do you write a complex sql query?

589


Differentiate between % rowtype and type record.

735


What are few of the schema objects that are created using PL/SQL?

563


What is a schema sql?

532


What is nosql vs sql?

570


Does a primary key have to be a number?

522