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
Can we insert in sql function?
What is composite primary key in sql?
what are ddl statements in mysql? : Sql dba
What is a data definition language?
How do I count duplicates in sql?
what is a database transaction? : Sql dba
What is a sql driver?
How can we solve sql error: ora-00904: invalid identifier?
What is cross join example?
Can a foreign key have a different name?
what is column? : Sql dba
What is the best free sql database?
what are local and global variables and their differences? : Sql dba
what is bcp? When is it used?
What is exception? What are the types of exceptions?