Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nickdotht/709ce317d8d907ae506e8015c91a0ab5 to your computer and use it in GitHub Desktop.
Save nickdotht/709ce317d8d907ae506e8015c91a0ab5 to your computer and use it in GitHub Desktop.
I use this to pull sales data so we can take care of duplicated sales
SELECT
kiosk.name AS 'Kiosk',
receipt.id as 'Receipt ID',
DATE_FORMAT(receipt.created_date, '%m/%d/%Y') AS Date,
customer_account.id AS 'Customer ID',
customer_account.contact_name AS 'Customer Name',
sales_channel.name AS 'Sales Channel',
receipt_line_item.sku AS 'SKU',
receipt_line_item.quantity 'Qty',
receipt.total_gallons 'Gallons',
receipt.total AS Total,
0 AS 'Is Duplicate'
FROM
receipt
INNER JOIN
kiosk ON kiosk.id = receipt.kiosk_id
INNER JOIN
customer_account ON customer_account.id = receipt.customer_account_id
INNER JOIN
sales_channel ON sales_channel.id = receipt.sales_channel_id
INNER JOIN
receipt_line_item ON receipt_line_item.receipt_id = receipt.id
WHERE
receipt.kiosk_id = 98
AND receipt.created_date BETWEEN '2017-08-01' AND '2017-09-01'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment