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 do you declare a constant?

0 Answers  


How to return more than one value from a function?

11 Answers   Satyam,


What is java sql driver?

0 Answers  


how to concatenate two character strings? : Sql dba

0 Answers  


what is a foreign key ? : Sql dba

0 Answers  






What is database white box testing and black box testing?

0 Answers  


What is difference between sql function and stored procedure?

0 Answers  


We have a CURSOR then we need BULK COLLECT?

1 Answers  


How many joins can you have in sql?

0 Answers  


Does sql*plus also have a pl/sql engine?

0 Answers  


What is error ora-01000: maximum open cursors exceeded

0 Answers  


What is the best partition size for windows 10?

0 Answers  


Categories