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 can you fetch first 5 characters of the string?
Lookups are a key component in sql server integration services (ssis). Explain its purpose?
How do I save a sql query?
how to create table with in the procedure or function?
The in operator may be used if you know the exact value you want to return for at least one of the columns.
Define tables and fields in a database
What is sql rowcount?
Enlist the characteristics of pl/sql?
What is aggregate function in sql?
What is group function in sql?
What is substitution variable in pl sql?
What is number function in sql?
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)