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
In what condition is it good to disable a trigger?
Does a join table need a primary key?
discuss about myisam key cache. : Sql dba
What are the different types of dbmss?
What is a full join sql?
What are the limitations of sql express?
What is the difference between an inner and outer join?
Is it possible to update views?
Difference between global and parameter variables?
How do I run pl sql in sql developer?
what is 'mysqld'? : Sql dba
what is the syntax for using sql_variant_property? : Transact sql
What are character functions in sql?
What are different types of triggers?
which command using query analyzer will give you the version of sql server and operating system? : Sql dba