I'm trying to write an SQL query that will output multiple variables depending on how many times a specific quantity exists in the DB. This information will then be used in a chart.
The DB is set as following:
ID | quantity | etc..
---------------------
1 | 2 |
2 | 6 |
3 | 1 |
4 | 2 |
.
.
.
Here is the query I made:
SELECT
COUNT(CASE WHEN quantity = 1) AS quantity1,
COUNT(CASE WHEN quantity = 2) AS quantity2
FROM orders
But I want it to output like this:
quantity1 | quantity2
---------------------
1 | 2 |
Instead I am getting these error messages:
Thanks in advance!
EDIT: If you want to test your code on my database, the link is below...
-Link Removed-