SELECT
name,
SUM(CASE WHEN val = 1 THEN amount ELSE 0 END) AS amountVal1,
SUM(CASE WHEN val = 2 THEN amount ELSE 0 END) AS amountVal2
FROM bank GROUP BY name
More Related Contents:
- SQL query rows as columns [duplicate]
- Efficiently convert rows to columns in sql server
- Convert Rows to columns using ‘Pivot’ in SQL Server
- Dynamic Pivot in Oracle’s SQL
- Simple way to transpose columns and rows in SQL?
- Oracle SQL pivot query
- How can I combine multiple rows into a comma-delimited list in Oracle? [duplicate]
- SQL transpose full table
- Pivot on Multiple Columns using Tablefunc
- How to pivot in SQLite or i.e. select in wide format a table stored in long format?
- TSQL Pivot without aggregate function
- Dynamically create columns sql
- TSQL PIVOT MULTIPLE COLUMNS
- Pivot rows to columns without aggregate
- Dynamic Pivot Columns in SQL Server
- SQL Server : dynamic pivot over 5 columns
- SQL – How to transpose?
- How to pivot rows into columns (custom pivoting)
- Sql PIVOT and string concatenation aggregate
- The new PIVOT function in BigQuery
- How to create a PivotTable in Transact/SQL?
- How to replace (null) values with 0 output in PIVOT
- Pivot data in T-SQL
- PIVOT query on Distinct records
- SQL Server PIVOT perhaps?
- In SQL Server how to Pivot for multiple columns
- TRANSFORM and PIVOT in Access 2013 SQL
- Pivoting in DB2
- Advice Using Pivot Table in Oracle
- I need to know how to create a crosstab query