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 / prasant kumar sahoo

Here I am giving the query in SQL in Vertical Out put
----------------------------------------------
select * from (select (select count(*) from (select
count(citino) from test1 where mails between 0 and 50 group
by citino) t1) as "0-50",
(select count(*) from (select count(citino) from test1 where
mails between 51 and 100 group by citino) t2) as "51-100",
(select count(*) from (select count(citino) from test1 where
mails between 101 and 150 group by citino) t3) as "101-150"
from test1) "Result" where rownum=1;
---------------------------------------------------
if u want to Horizontal out put it need an another table
that store the range like 0-50,51-100 like. And then U just
Join this it so easy. If you need then, mail me
---------------------------------------------
if you need in Plsql also mail me I will send you

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between microsoft sql and mysql?

513


What is pl sql collection?

527


How to write a single statement that concatenates the words ?hello? And ?world? And assign it in a variable named greeting?

650


What is sql mysql pl sql oracle?

581


Can ddl statements be used in pl/sql?

598






Write the alter statement to enable all the triggers on the t.students table.

677


What is %s in sql?

572


What is a subquery in sql?

512


Is oracle sql free?

545


Why stored procedures are faster than query?

570


How do I remove duplicates in two columns?

510


How to add a column ‘salary’ to a table employee_details?

595


Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

584


What are tuples in sql?

571


how to run 'mysql' commands from a batch file? : Sql dba

613