Basically, I have a query like this:

```
SELECT dc.email, SUM(bft.amount_usd) AS TOTALSPENT,
SUM(CASE WHEN doct.Product_name = 'Books' THEN bft.amount_usd ELSE 0 END) TOTALSPENT_BOOKS,
SUM(CASE WHEN doct.Product_name = 'Shoes' THEN bft.amount_usd ELSE 0 END) TOTALSPENT_SHOES,
COUNT(DISTINCT CASE WHEN doct.CATEGORY_A = 1 THEN doct.order_guid ELSE NULL END) CATEGORY_A_count,
COUNT(DISTINCT CASE WHEN doct.CATEGORY_B = 1 THEN doct.order_guid ELSE NULL END) CATEGORY_B_count,
COUNT(DISTINCT CASE WHEN doct.CATEGORY_C = 1 THEN doct.order_guid ELSE NULL END) CATEGORY_C_count,
COUNT(DISTINCT CASE WHEN doct.CATEGORY_D = 1 THEN doct.order_guid ELSE NULL END) CATEGORY_D_count
FROM ProductTypeTable doct
INNER JOIN customerTable dc ON dc.customerID = doct.customerID
INNER JOIN transactionsTable bft ON bft.transactionID = doct.transactionID
GROUP BY dc.email
```

**CATEGORY_A** - is a Boolean field (1/0)

**CATEGORY_B** - is a Boolean field (1/0)

**CATEGORY_C** - is a Boolean field (1/0)

**CATEGORY_D** - is a Boolean field (1/0)

**My output and desired output is:**

How my query should look like to get the desired output?