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
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 |
how to rename an existing column in a table? : Sql dba
is mysql query is case sensitive? : Sql dba
How do I view a procedure in sql?
Which is the best place to learn hadoop?
what is data integrity
Why do we create stored procedures & functions in pl/sql and how are they different?
How is sql used in oracle?
what are the 'mysql' command line options? : Sql dba
what is global temporary tables and how use that tables in pl/sql packages
What are the main features of cursor?
What do you mean by query optimization?
what is the order of pre-defined exceptions.
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)