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

What is a sql statement?

537


How do I start pl sql?

493


Does sql use python?

565


What is Collation Sensitivity ? What are the various type ?

501


What is data abstraction in sql?

515






Is a foreign key always unique?

536


What is the difference between row level and statement level trigger?

526


write an sql query to find names of employee start with 'a'? : Sql dba

584


Explain what is a view?

600


Explain the difference between 'between' & 'and' operators in sql

531


What are different types of keys?

526


Why use stored procedures?

577


What is the use of procedures?

546


If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????

3550


how to include character strings in sql statements? : Sql dba

557