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
How do I find duplicates in sql?
How do I partition a table in sql?
What type of database is cloud sql?
Why do we need cursors in pl sql?
Do ddl statements need commit?
What do you mean by rowid?
Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?
What has stored procedures in sql and how we can use it?
Write the alter statement to enable all the triggers on the t.students table.
The select into statement is most often used to create backup copies of tables or for archiving records?
What is the use of primary key?
What is partition by in sql?
What is the use of index in hive?
Is sql better than access?
what is data control language? : Sql dba