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
What are expressions?
What are the methods of filing?
Difference between table function and pipelined function?
what are null values? : Sql dba
What is primary and foreign key?
Is sql harder than python?
What is normalization in a database?
How to execute a stored procedure?
How do you respond to dementia behavior?
Is sql a backend language?
What is sql deadlock?
how to include comments in sql statements? : Sql dba
What is meant by cursor in sql?
What are the different types of constraints?
Are stored procedures compiled?