Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do I find duplicates in sql?

939


How do I partition a table in sql?

1141


What type of database is cloud sql?

1110


Why do we need cursors in pl sql?

1093


Do ddl statements need commit?

978


What do you mean by rowid?

986


Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

1109


What has stored procedures in sql and how we can use it?

1087


Write the alter statement to enable all the triggers on the t.students table.

1131


The select into statement is most often used to create backup copies of tables or for archiving records?

1072


What is the use of primary key?

1012


What is partition by in sql?

1077


What is the use of index in hive?

1007


Is sql better than access?

1023


what is data control language? : Sql dba

1033