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 / anjan ghosh
create table xyz ( x varchar2(30),y varchar2(30),z number);
insert into xyz values (6 , 'HEBBAL' ,115);
select count(*) as No_of_city , '0-50' as Distance from xyz
where z between 0 and 50
union all
select count(*)as No_of_city ,'51-100' as Distance from
xyz where z between 51 and 100
union all
select count(*)as No_of_city ,'101-150' as Distance from
xyz where z between 51 and 100
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why self join is used in sql?
what are null values? : Sql dba
How do I upgrade sql?
is mysql query is case sensitive? : Sql dba
Is foreign key mandatory?
What is the difference between numeric and autonumber?
Differentiate between sga and pga.
Can I join the same table twice?
What is server name sql?
Explain the advantages and disadvantages of stored procedure?
What action do you have to perform before retrieving data from the next result set of a stored procedure ?
Explain the difference in execution of triggers and stored procedures?
What is file based approach?
what is sub-query? : Transact sql
What is difference between sql function and stored procedure?