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
Is join an inner join?
How to avoid duplicate records in a query?
What plvcmt and plvrb does in pl/sql?
What are the three forms of normalization?
what are the 'mysql' command line options? : Sql dba
what is oltp (online transaction processing)? : Sql dba
What is trigger and how to use it in sql?
what is auto increment? : Sql dba
What is structural independence and why is it important?
Is oracel sql developer written in java?
what is sql? : Sql dba
What is sql basics?
Which normal form is best?
Why having clause is used in sql?
How do you update a sql procedure?