forked from untapped-inc/sema-database
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreceipt_details_view.sql
More file actions
28 lines (28 loc) · 975 Bytes
/
receipt_details_view.sql
File metadata and controls
28 lines (28 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
CREATE VIEW `receipt_details` AS
SELECT
receipt_line_item.created_at,
receipt_line_item.quantity,
receipt_line_item.product_id,
receipt_line_item.receipt_id,
receipt.sales_channel_id,
receipt.kiosk_id,
receipt.amount_cash,
receipt.amount_loan,
receipt.amount_mobile,
receipt.amount_card,
receipt.customer_account_id,
product.unit_per_product,
receipt_line_item.quantity * product.unit_per_product AS volume,
receipt.total,
customer_account.name,
customer_account.income_level,
customer_account.customer_type_id,
receipt.active
FROM
receipt_line_item
INNER JOIN
receipt ON receipt_line_item.receipt_id = receipt.id
INNER JOIN
product ON receipt_line_item.product_id = product.id
INNER JOIN
customer_account ON receipt.customer_account_id = customer_account.id;