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
How do I find duplicates in two columns?
what is sql profiler? : Sql dba
what are the types of join and explain each? : Sql dba
How to get list of all tables from a database?
What are system versioned tables?
What is latest version of sql?
Can we join same table in sql?
Is sql a scripting language?
What is the purpose of a sql?
How do you select unique values in sql?
What are the different schemas objects that can be created using pl/sql?
Explain the uses of database trigger.
How do I view a sql trace file?
What is the difference between the conventional and direct path loads? : aql loader
What is rowid in sql?