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

Does sql profiler affect performance?

561


What is primary key in db?

523


Can we use pl sql in mysql?

521


What trigger means?

568


What is assignment operator in pl sql?

572






What are the different types of a subquery?

525


What is varchar example?

578


What are the different types of functions in sql?

516


Explain constraints in sql?

575


What is latest version of sql?

530


GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?

2578


How do you write an index?

529


How can we store rows in PL/SQL using array?

669


What is sql lookup?

516


What is the maximum rows in csv?

493