SELECT budget_id,
SUM(IF(type="allocation", points, 0)) AS allocated,
SUM(IF(type="issue", points, 0)) AS issued
FROM transactions
GROUP BY budget_id
More Related Contents:
- get first occurrence of last changed value of a column [closed]
- MySQL – Rows to Columns
- ROW_NUMBER() in MySQL
- WHERE vs HAVING
- Join tables with SUM issue in MYSQL
- Strange duplicate behavior from GROUP_CONCAT of two LEFT JOINs of GROUP_BYs
- Return default result for IN value regardless
- How can I search (case-insensitive) in a column using LIKE wildcard?
- Search for “whole word match” in MySQL
- sql joins as venn diagram
- How can I join multiple SQL tables using the IDs?
- Check if MySQL table exists without using “select from” syntax?
- MySQL, better to insert NULL or empty string?
- SQL: selecting rows where column value changed from previous row
- Why do results from a SQL query not come back in the order I expect?
- How to generate data in MySQL?
- MySQL combine two columns and add into a new column
- SQL query of multiple values in one cell
- How to skip certain database tables with mysqldump?
- MySQL error 1241: Operand should contain 1 column(s)
- How to set a MySQL row to READ-ONLY?
- How to transpose rows to columns with large amount of the data in BigQuery/SQL?
- Mysql: Order by like?
- Getting first day of the week in MySql using Week No
- Is there a way to get the row number in Mysql like the rownum in oracle [duplicate]
- How to get a list of months between two dates in mysql
- How to format number with “.” as thousands separator and “,” as decimal separator?
- Using DISTINCT and COUNT together in a MySQL Query
- How to check if field is null or empty in MySQL?
- SQL date format convert? [dd.mm.yy to YYYY-MM-DD]