Most useful SQL Query examples. I would like now to review my own direct knowledge and experiences with SQL and Queries. First we will start with more than one table. 1. Table Joining. For this example, we will use the Customer and Orders tables. The Customer table has Customer_ID, a unique key for each customer. Customer Table: Customer_ID Name Street City State Zip Country Phone Email Social1 (we will store several social media accounts as Social1-10.) Orders_Header: Customer_ID Order# Total order$ Order_date Ship_date Discount1 (We might have more than 1 discount per order) Promo1 Invoice# Orders_detail Customer_ID Order# Order_ext (this will be a counter of every order per the customer) Part# (this is the item #) Price Part_Discount1 Part_Promo1 there will be multiple rows usually. Shipping charge, will be a separate row. Even if there is a promo for free shipping. Now we want to see which customers bought the most products in a given month. We want to show who had most orders per month, and highest Total$. We would also like to see amongst those who used a Discount code, bought which part#

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home