Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question No 2 [10 marks] CREATE TABLE SALES ( SALE_ID INTEGER, PRODUCT_ID INTEGER, YEAR INTEGER, QUANTITY INTEGER, PRICE INTEGER ); Consider the product schema (given

Question No 2 [10 marks]

CREATE TABLE SALES

(

SALE_ID INTEGER,

PRODUCT_ID INTEGER,

YEAR INTEGER,

QUANTITY INTEGER,

PRICE INTEGER

);

  1. Consider the product schema (given above) to answer the following questions.

  1. Write a SQL query which retrieves product it and total quantity of bestselling product (i.e., largest quantity product) in each year.

  1. Write a SQL query which retrieves three highest and three lowest price products in the sales table.

  1. Write a SQL query using the analytic function to find the total sales of each product? Sample outcome of the SQL statement is given below.

PRODUCT_ID QUANTITY TOT_SALES

----------------------------------------------------------

100 12 22

100 10 22

200 15 25

200 10 25

  1. Write a SQL query to find the cumulative sum of sales(QUANTITY) of each product? Sample outcome of the SQL statement is given below.

PRODUCT_ID QUANTITY CUM_SALES

----------------------------------------------------------

100 8 8

100 10 18

100 12 30

200 10 10

200 13 23

200 14 37

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago