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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / lizamishra15

pls answer me this qeustion

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

How can you tell the difference between an index and a view?

0 Answers  


what is normalization? : Sql dba

0 Answers  


how many triggers are allowed in mysql table? : Sql dba

0 Answers  


Explain about various levels of constraint.

0 Answers  


Why is a primary key important?

0 Answers  






What is difference between pls_integer and integer?

0 Answers  


How do I remove sql plus from windows 10?

0 Answers  


Types of indexes. What is the default key created when a primary key is created in a table ?

5 Answers   TCS,


Why truncate is used in sql?

0 Answers  


How to disable a trigger name update_salary?

0 Answers  


what is the difference between implicit conversions and explicit conversions?

2 Answers  


What is sql*loader?

0 Answers  


Categories