Hello,
I have two tables that I am trying to run a Left Join on after I have filtered them with a WHERE condition. I want to filter the Customer table to only the records that are in the customer_group "Investor Owned Util". Then I want to filter the Orders table to only the records with a sales_credit_date after January 1, 2016. Finally, I want to take these two resulting tables and show all the results from the Customer table and any orders that were placed by each of the customers. The problem is that when I try to run the query I get a "Syntax error in Union Query". I have tried a few different versions of what is shown below but nothing is working. The only query I got to run would join the tables first and then filter on the WHERE clause which would result in leaving out any customers that did not place an order this year. I need the WHERE clause to filter first and then JOIN the resulting tables. Any help is greatly appreciated.
(SELECT ship_to_party, sold_to_party, customer_group FROM Customer WHERE customer_group = "Investor Owned Util")
LEFT JOIN
(SELECT sales_order_number, order_ship_to_party, sales_credit_date FROM Orders WHERE sales_credit_date > #1/1/2016#)
ON cust.ship_to_party = ord.order_ship_to_party
Thanks,
joker16
I have two tables that I am trying to run a Left Join on after I have filtered them with a WHERE condition. I want to filter the Customer table to only the records that are in the customer_group "Investor Owned Util". Then I want to filter the Orders table to only the records with a sales_credit_date after January 1, 2016. Finally, I want to take these two resulting tables and show all the results from the Customer table and any orders that were placed by each of the customers. The problem is that when I try to run the query I get a "Syntax error in Union Query". I have tried a few different versions of what is shown below but nothing is working. The only query I got to run would join the tables first and then filter on the WHERE clause which would result in leaving out any customers that did not place an order this year. I need the WHERE clause to filter first and then JOIN the resulting tables. Any help is greatly appreciated.
(SELECT ship_to_party, sold_to_party, customer_group FROM Customer WHERE customer_group = "Investor Owned Util")
LEFT JOIN
(SELECT sales_order_number, order_ship_to_party, sales_credit_date FROM Orders WHERE sales_credit_date > #1/1/2016#)
ON cust.ship_to_party = ord.order_ship_to_party
Thanks,
joker16