Mysql Database Query 04.12.08
I have a MYSQL database with a table named “orders” and a table named “orders_products” These two tables have all the information required for the following query.
I would like you to produce a MySQL query that will create the following output
(based on a variable date range ie: Jan 01 2007 – Dec 31 2007)
(in the orders table)
1) total gross sales for two countries ($Canada – $USA)
2) total provincial tax collected ($Canada)
3) total federal tax collected ($Canada)
4) total cost of sales ($USA)
Your query will have to associate the
orders_products_id (orders_products table)
with the orders_id (orders table)
to add the sales all of the products and their quantities associated with an order (orders_products table) to the total sales for the period queried (orders table)
It will also have to adjust this total for the currency exchange rate used on each order (orders table) if the order
delivery_country = Canada (orders table)
It will also have to adjust this Canadian total based on two different tax multipliers
products_tax_provincial – decimal(7,4) (orders_products table) and
products_tax – decimal(7,4) (orders_products table)
This is basically what is required.
I would like the output to be in the form of a total but am ok with a php or other data dump that can be pulled into Excel.
I am leaving for the weekend but can respond to any questions on
Monday when i return.




















