Last active
December 30, 2016 08:18
-
-
Save debuggerpk/565eb6e9f09c8a375eaa2b3186fdce5b to your computer and use it in GitHub Desktop.
creating view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE VIEW "lineitems_vista" AS | |
| SELECT | |
| id, | |
| created_at, | |
| updated_at, | |
| shift_id, | |
| itms.name as name, | |
| quantity, | |
| transaction_id, | |
| itms.price as unit_price, | |
| itms.price*quantity as item_total, | |
| itms.category_id, | |
| category, | |
| family | |
| FROM line_items | |
| LEFT JOIN ( | |
| SELECT name, price, category_id, id as iid FROM items | |
| ) as itms ON line_items.item_id = itms.iid | |
| LEFT JOIN ( | |
| SELECT created_at, updated_at, shift_id, id as tid FROM transactions | |
| ) as trnsctns ON line_items.transaction_id = trnsctns.tid | |
| LEFT JOIN ( | |
| SELECT family, name as category, id as cid FROM categories | |
| ) as ctgrs ON itms.category_id = ctgrs.cid; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment