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
Write a sql query to find the names of employees that begin with ‘a’?
Are sql database names case sensitive?
what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba
Explain two easy sql optimizations.
Can pl sql procedure have a return statement?
What are the possible values that can be stored in a boolean data field?
What is the least restrictive isolation level? : Transact sql
How do you modify a table in sql?
What programs use sql?
is it possible to pass an object or table to a procedure as an argument?
What is an index in sql with example?
Which is better join or subquery?
What is the difference between left join and right join?
what are the differences among rownum, rank and dense_rank? : Sql dba
Why do we create views in sql?