Hi all. I've had awesome responses here thus far (actually better than most sql forums if you can believe that lol).
Anyway here's the query I'm writing. And I've also included output. The division areas of my query are not working. I'm returning 0's. I think one solution is to drop the counts/sums into a table, and then query that second table, but I feel like that's an unnecessary step and my syntax is off.
Please see the query / output.
SELECT
DATE_TRUNC('month', n.campaign_date)
-- , n.campaign_cell_id
-- , n.legacy_campaign_id
-- , n.components
-- , n.envelope_creative
-- , n.envelope_format
-- , n.offer
-- , n.segment
, COUNT(n.nucleus_business_id) Members
, SUM(n.responded) Responses
, AVG(n.score) score
, COUNT(n.opp_id) applications
, COUNT(n.completed_app_date) completed_applications
, COUNT(n.approval_date) approvals
, SUM(n.closed_won) loans
,SUM(n.responded) / COUNT(n.nucleus_business_id) Response_Rate
,COUNT(n.opp_id) Applications
,COUNT(n.opp_id) / SUM(n.responded) App_Rate
,COUNT(n.completed_app_date) completed_applications
,COUNT(n.completed_app_date) / COUNT(n.opp_id) CA_Rate
,COUNT(n.approval_date) approvals
,COUNT(n.approval_date) / COUNT(n.opp_id) Apps_Approvals
,SUM(n.closed_won) Loans
,SUM(n.closed_won) / COUNT(n.approval_date) Booking_Rate
,SUM(n.closed_won) / SUM(n.responded) Responses_ToClose
,SUM(n.closed_won) / COUNT(n.nucleus_business_id) Mailer_Close
FROM
mining_space.nucleus_camp_memb n
WHERE
n.campaign_date > '2014-12-01'
GROUP BY
1
ORDER BY 1
HERE'S THE OUTPUT
