Answer the question
In order to leave comments, you need to log in
How to use count/sum with double condition?
The task is to count the number of ordered goods by country of order.
There is a table:
ID | item_name | meta_value
The meta_value contains various product characteristics, including the country and the number of products in the order.
Without the quantity in the order, I get the data from the database like this (here I get an array of all orders):
SELECT
meta_value AS country,
count(case when item_name = '%ITEM_NAME_1%' then 1 else null end) AS count_1
count(case when item_name = '%ITEM_NAME_2%' then 1 else null end) AS count_2
GROUP BY meta_value
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question