query skills demo using northwind database

Upload: marko-djurdjevic

Post on 03-Jun-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Query Skills Demo Using Northwind Database

    1/4

    Demo of Basic Query Skills

    Using theNorthwind.accdbdatabase

    Solutions are provided on the following pages.

    From a single table:Products.1. What products are in Northwinds Products table!. What is the price of each product". Which products are most e#pense and which are least e#pensive $%ist all

    products and their prices in descending order.&'. Which products have been discontinued(. Which current products cost less than )1*+. Which current products cost between )1* and )!* $two variations&,. Which current products are in danger of going out of stoc- $uantit/ in stoc-

    is less than the 0uantit/ on order&. 2ow man/ current products and how man/ discontinued products are there

    From two tables:Products and Categories.

    1. What products e#ist in each categor/!. Same 0uestion3 but alphabeti4e the list b/ categor/ and product.". 2ow man/ products are there in each categor/'. What is the average price in each categor/ $sort from highest to lowest&

    From four tables:Products, OrderDetails, Orders and Customers.

    1. (Customer preferences)%ist all of the products each customer has everordered 5 sorted b/ customer and product.

    !. (High-ariet!-to-low-ariet! customers)2ow man/ different -inds ofproducts each customer has ordered 5 sorted b/ product Sort high to low.

    ". (High-end-to-low-end customers)What is the average price of the productseach customer has ordered Sort high to low.

    '. ("noice)What is the e#tension $price # 0uantit/& of each product on eachorder for each customer $6 calculated field is needed here. 6lso include theorder date.&

    (. (#mount due)What is7was the total amount owed on each order

    +. ($est customers)What is the total amount purchased b/ each customer $%istin descending order.&

    ,. (%ost-widel!-popular-to-least-widel!-popular products) What products havebeen purchased b/ the most customers $%ist in descending order&

  • 8/12/2019 Query Skills Demo Using Northwind Database

    2/4

    &olutions

    8o see how to answer a 0uestion above31. 9op/ the S% statement below $one at a time&.!. Paste it into the S% window in /our 0uer/ designer.

    ". 8hen switch to the esign view of the 0uer/.

    From a single table:Products.

    1 What products are in NorthwindsProducts table

    S;%;98 Products.ProductName F Products?

    ! What is the price of eachproduct

    S;%;98 Products.ProductName3 Products.UnitPrice FProducts?

    " Which products are most e#penseand which are least e#pensive$%ist all products and their pricesin descending order.&

    S;%;98 Products.ProductName3 Products.UnitPrice FProducts=

  • 8/12/2019 Query Skills Demo Using Northwind Database

    3/4

    From two tables:Products and Categories.

    1 What products e#ist in eachcategor/

    S;%;98 9ategories.9ategor/Name3 Products.ProductNameF 9ategories NN;< J=N Products =N9ategories.9ategor/ B Products.9ategor/?

    ! Same 0uestion3 but alphabeti4ethe list b/ categor/ and product.

    S;%;98 9ategories.9ategor/Name3 Products.ProductNameF 9ategories NN;< J=N Products =N9ategories.9ategor/ B Products.9ategor/=

  • 8/12/2019 Query Skills Demo Using Northwind Database

    4/4

    From four tables:Products, OrderDetails, Orders and Customers.

    1 (Customer preferences)%ist all of the productseach customer has everordered 5 sorted b/customer and product.

    S;%;98 9ustomers.9ompan/Name3 Products.ProductNameF $9ustomers NN;< J=N =rders =N 9ustomers.9ustomer B =rders.9ustomer&NN;< J=N $Products NN;< J=N G=rder etailsH =N Products.Product B G=rderetailsH.Product& =N =rders.=rder B G=rder etailsH.=rder=