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
Answer Posted / kavitha nedigunta
SELECT DISTANCE,COUNT(*) NO_OFCITY
from
(SELECT (CASE WHEN TO_NUMBER(RTRIM(MAILS,'KM')) BETWEEN 0
AND 50 THEN '0-50'
WHEN TO_NUMBER(RTRIM(MAILS,'KM')) BETWEEN 51 AND
100 THEN '51-100'
ELSE '101-150' END) DISTANCE
FROM TEST001) A
GROUP BY DISTANCE
order by to_number(replace(DISTANCE,'-',''))
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
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????
What is a primary key called that is made up of more than one field?
Can we create table in function?
how to use like conditions? : Sql dba
What is the use of prepared statement?
i have 2 table table one 4 columns respective values a1 7,a2 6,a3 8 ,a4 12 & table two 4 colums respective values a1 7,a2 6,a3 8,a4 15.if table one & table two 3 colums same then 4th column values 1)Qes diff >5 then print 5 * diff value 2)Que diff <5 print 5
Can we write ddl statements in functions?
What are analytical functions in sql?
Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql
What are the 3 modes of parameter?
Why do we need cursor in pl sql?
What is materialized view in sql?
How to execute a stored procedure?
How to display Row Number with Records in Oracle SQL Plus?
what is a primary key? : Sql dba