Skip to content

Instantly share code, notes, and snippets.

@shofetim
Created May 13, 2013 16:09
Show Gist options
  • Select an option

  • Save shofetim/5569471 to your computer and use it in GitHub Desktop.

Select an option

Save shofetim/5569471 to your computer and use it in GitHub Desktop.
SELECT
CONCAT('D', dp.id) AS "Drop Point Number",
dp.contact_name AS "Name"
CASE customer.price_level
WHEN 1 THEN 'No'
WHEN 2 THEN 'Yes'
ELSE 'Unknown'
END AS "Wholesale?"
FROM drops_droppoint AS dp
INNER JOIN drops_droppointmanagerpreferences AS pref
ON dp._preferences_id = pref.id
LEFT JOIN drops_droppointmembership AS membership
ON membership.drop_point_id = dp.id
INNER JOIN customers_customer AS customer
ON customer.id = membership.customer_id
WHERE
dp._preferences_id IS NOT NULL AND
pref.driver_callable_phone IS NOT NULL AND
pref.customer_callable_phone IS NOT NULL AND
pref.members_receive IS NOT NULL AND
pref.hold_time IS NOT NULL AND
pref.contact_need IS NOT NULL AND
pref.drop_fees IS NOT NULL AND
pref.fee_amount_and_structure IS NOT NULL AND
pref.publishable IS NOT NULL AND
pref.new_members IS NOT NULL AND
pref.other_contact IS NOT NULL AND
pref.accept_cod IS NOT NULL AND
pref.parking_type IS NOT NULL AND
pref.other_parking IS NOT NULL
GROUP BY dp.id, customer.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment