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...

table having two columns - entity,zone
enity zone
pen east
pen west
pen north
pen south
pen east
pencil east
pencil east
pencil west

I want the output as :
entity east west north south
pen 2 1 1 1
pencil 2 1 0 0

Answer Posted / aswini mohanty

select entity,sum(decode(zone,'east',1,0)) east,
sum(decode(zone,'west',1,0)) west,
sum(decode(zone,'north',1,0))north,
sum(decode(zone,'south',1,0))south
from t group by entity;

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In what condition is it good to disable a trigger?

1016


Does a join table need a primary key?

959


discuss about myisam key cache. : Sql dba

1024


What are the different types of dbmss?

1015


What is a full join sql?

1062


What are the limitations of sql express?

1074


What is the difference between an inner and outer join?

1020


Is it possible to update views?

963


Difference between global and parameter variables?

1973


How do I run pl sql in sql developer?

1124


what is 'mysqld'? : Sql dba

978


what is the syntax for using sql_variant_property? : Transact sql

1050


What are character functions in sql?

943


What are different types of triggers?

1114


which command using query analyzer will give you the version of sql server and operating system? : Sql dba

1065