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 / js

SELECT R,COUNT(R) FROM
(
SELECT cityname,mail,
CASE WHEN SUBSTR(MAIL,1,INSTR(MAIL,'KM' )-1) BETWEEN 0 AND 50 THEN '0-50'
WHEN SUBSTR(MAIL,1,INSTR(MAIL,'KM' )-1) BETWEEN 51 AND 100 THEN '51-100'
ELSE '101-150' END R FROM CITY) GROUP BY R;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we rollback truncate?

1004


What is sql basics?

1046


How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?

1144


How do I view a sql database?

1023


Write the order of precedence for validation of a column in a table? I. Done using database triggers. Ii. Done using integarity constraints

1080


Is pl sql better than sql?

1042


Does sap use sql?

997


What is attribute indicator in pl sql?

1017


Why do we need databases?

1052


Is a foreign key always unique?

949


What is cost in sql execution plan?

990


how to check myisam tables for errors? : Sql dba

1324


What is the command used to fetch the first 5 characters of a string?

1212


How many postgresql users are there, worldwide?

1069


What's the difference between a primary key and a clustered index?

989