I have the following simple table which you can also find in the SQL Fiddle
here:
CREATE TABLE Orders (
Customer TEXT,
Order_Date DATE
);
I
Just add that to the select
:
SELECT o.Customer,
SUM( o.Order_Date >= '2019-02-01' AND o.Order_Date < '2019-03-01' ) as num_feb_orders
FROM ORDERS o
GROUP BY o.Customer
HAVING SUM( o.Order_Date >= '2019-02-01' AND o.Order_Date < '2019-03-01' ) > 0 AND
SUM( o.Order_Date >= '2018-01-02' AND o.Order_Date < '2019-02-01' ) = 0 AND
SUM( o.Order_Date < '2018-01-02' ) > 0 ;