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

pls give me answer. i want urgent

Answer Posted / anjan ghosh

create table xyz ( x varchar2(30),y varchar2(30),z number);

insert into xyz values (6 , 'HEBBAL' ,115);

select count(*) as No_of_city , '0-50' as Distance from xyz
where z between 0 and 50
union all
select count(*)as No_of_city ,'51-100' as Distance from
xyz where z between 51 and 100
union all
select count(*)as No_of_city ,'101-150' as Distance from
xyz where z between 51 and 100

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is audit logout in sql profiler?

590


How many types of privileges are available in sql?

739


What is the purpose of normalization?

536


Mention what is the use of function "module procedure" in pl/sql?

569


Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?

722






Explain table and field in sql?

584


Explain the the update statement in sql?

571


What are the types of triggers in sql?

500


What does pl sql stand for?

657


Why do we need cursors in pl sql?

521


what are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee (eno int(2),ename varchar(10)) ? : Sql dba

617


what are all different types of collation sensitivity? : Sql dba

525


How do I count rows in sql query?

491


Why use subqueries instead of joins?

608


What is a .db file?

544