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

What is serial sql?

0 Answers  


write a pl/sql function if enter a value=0 then output value=1 and vise verse with out using if and case statements.

3 Answers   Zensar,


What is percent sign in sql?

0 Answers  


How do you go back in sql?

0 Answers  


what is timestamp in mysql? : Sql dba

0 Answers  






Could you please provide oca (oracle 10g) dumps for my certification ?

1 Answers  


Is sql a programming?

0 Answers  


Why sql query is slow?

0 Answers  


How many types of triggers are there in pl sql?

0 Answers  


What are the benefits of triggers?

0 Answers  


what is the difference between a having clause and a where clause? : Sql dba

0 Answers  


what is the difference between sql and t-sql? : Transact sql

0 Answers  


Categories