I'm using an Oracle SQL database. I'm trying to combine this 2 queries into one from same table:
select count(CustomerID) from Customers
where (City = 'Berlin' or City = 'London')
from Customers;
select count(CustomerID) from Customers
where (City = 'Mannheim' or City = 'Strasbourg')
from Customers;
And my output would like to be something like exported on 2 columns:
| Berlin & London | Mannheim & Strasbourg |
|-----------------------------------------|
| 5 | 10 |
example of db here, https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_in
I think the answer will be:
(select count(CustomerID) from Customers
where (City = 'Berlin' or City = 'London'))
union
(select count(CustomerID) from Customers
where (City = 'Marseille' or City = 'Tsawassen'));
union
(select count(CustomerID) from Customers
where (City = 'Strasbourg' or City = 'Madrid'));
Still testing...
Finally got the job done by using this case. Thanks to everyone involved !
SELECT
COUNT(CASE
WHEN work_zone = 'AMBGI01' OR
work_zone = 'AMBGI02' OR
work_zone = 'AMBGI03' AND
task_type = 'P' THEN work_zone
END) "HighBay Putaways",
COUNT(CASE
WHEN work_zone = 'AMBGI04' OR
work_zone = 'AMBGI05' OR
work_zone = 'AMBGI06' OR
work_zone = 'AMBGI07' AND
task_type = 'P' THEN work_zone
END) "LowBay Putaways",
COUNT(CASE
WHEN from_loc_id = 'THEWALL' AND
task_type = 'P' THEN from_loc_id
END) "THE WALL",
COUNT(CASE
WHEN tag_id like '%' AND
from_loc_id like 'EXPANS%' AND
task_type = 'P' THEN tag_id
END) "EXPANSION",
COUNT(CASE
WHEN final_loc_id like '_______' AND
(status = 'In Progress' OR
status = 'Released') AND
task_type = 'R' THEN final_loc_id
END) "Replens"
FROM move_task;
(select count(CustomerID) from Customers where (City = 'Berlin' or City = 'London')) union (select count(CustomerID) from Customers where (City = 'Marseille' or City = 'Tsawassen')); union (select count(CustomerID) from Customers where (City = 'Strasbourg' or City = 'Madrid'));but not sure if working 100%