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

SQL> select * from quest;

Cityno cityname mails
---------- -------------------- ----------
1 bangalore 8km
2 hsr layout 20km
3 mejistic 30km
4 jayadeva 55km
5 itpl 80km
6 hebbal 115km

6 rows selected.

SQL> with data as (
2 select level as lvl,lag(level,1,0) over(order by level) as pre_lvl
3 from dual
4 where mod(level,50) = 0
5 connect by level <=150)
6 select count(cityno),pre_lvl||'-'||lvl
7 from quest
8 ,data
9 where to_number(replace(mails,'KM',0))/10 between pre_lvl and lvl
10 group by lvl,pre_lvl;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of functions are there in sql?

899


What is a file delimiter?

1016


What is blind sql injection?

992


What is the use of non clustered index?

930


What packages(if any) has oracle provided for use by developers?

5719


What do you mean by “trigger” in sql?

1019


What is java sql package?

1026


how many triggers are allowed in mysql table? : Sql dba

997


Why do we create views in sql?

1055


Define the select into statement.

997


What is a Mapplet?

1058


What are the advantages of pl sql over sql?

964


What does where 1/2 mean in sql?

1012


what is cross join? : Sql dba

941


what is index? : Sql dba

946