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

pls give me answer. i want urgent

Answer Posted / senthil

hi,
if mails field is numeric above query is correct but mails filed is varchar that is contain 'km' so test my query....
Ex:
select RANGE distance,count(range) no_of_city
from
(SELECT citiname,mails,
CASE WHEN to_number(substr(mails,0,(instr(mails,'k')-1))) BETWEEN 0 AND 50 THEN '0-50'
WHEN to_number(substr(mails,0,(instr(mails,'k')-1))) BETWEEN 51 AND 100 THEN '51-100'
ELSE '101-150'
END RANGE
FROM test1) group by range

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible for a table to have more than one foreign key?

980


what is single byte over head in oracle..?

2342


How many types of keys are there in sql?

988


What is thread join () in threading?

948


What does count (*) do in sql?

954


how to shut down the server with 'mysqladmin'? : Sql dba

958


What is the most restrictive isolation level? : Transact sql

1028


What are the types pl/sql code blocks?

1069


what is online transaction processing (oltp)? : Sql dba

938


Mention what does plv msg allows you to do?

1054


What is sql character function?

996


Can unique keys be null?

853


What is the importance of sqlcode and sqlerrm?

1280


What is the difference among union, minus and intersect?

950


Is sql a microsoft product?

898