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

Answer in Horizontal out put
select RANGE distance,count(range) no_of_city
from
(SELECT citiname,mails,
CASE WHEN MAILS BETWEEN 0 AND 50 THEN '0-50'
WHEN MAILS BETWEEN 51 AND 100 THEN '51-100'
ELSE '101-150'
END RANGE
FROM test1)
group by range;

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we use ddl statements in stored procedure?

696


What is replication id?

521


what is query cache in mysql? : Sql dba

577


Which are the different character-manipulation functions in sql?

548


What is sql rowcount?

559






What is sql exception?

517


How to use distinct and count in sql query? Explain

612


What version is sql?

553


How many tables can you join in sql?

535


Does sql*plus also have a pl/sql engine?

563


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

539


What are the types of index in sql?

533


What are the commands used in sql?

527


what is a table in a database ? : Sql dba

542


List different type of expressions with the example.

551