0% found this document useful (0 votes)
95 views4 pages

04 Laboratory Exercise 1

This document provides instructions for a laboratory exercise on using the ROLLUP, CUBE, and PIVOT operators in SQL Server to perform OLAP-type operations. Students will insert sample data on phone purchases into an online SQL database. They will then write queries using ROLLUP to calculate totals by brand and month, CUBE to show totals by brand and month as well as grand totals, and PIVOT to display monthly purchase amounts and brand subtotals. Their code will be evaluated on correctness, logic, efficiency, and syntax.

Uploaded by

Jaquilyn Rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views4 pages

04 Laboratory Exercise 1

This document provides instructions for a laboratory exercise on using the ROLLUP, CUBE, and PIVOT operators in SQL Server to perform OLAP-type operations. Students will insert sample data on phone purchases into an online SQL database. They will then write queries using ROLLUP to calculate totals by brand and month, CUBE to show totals by brand and month as well as grand totals, and PIVOT to display monthly purchase amounts and brand subtotals. Their code will be evaluated on correctness, logic, efficiency, and syntax.

Uploaded by

Jaquilyn Rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

IT2003

Laboratory Exercise
Rollup and Cube
Objective:

At the end of the exercise, the students should be able to:

 Execute OLAP-type operations using the ROLLUP, CUBE, and PIVOT operators.

Software Requirement:

 Microsoft SQL Server Management Studio 18.0 or higher


 Microsoft SQL Server Express 2017

Procedures:
1. Go to https://sqliteonline.com. In the left-side corner, expand the MS SQL tab then click the Click to
connect.
Note: After 15 minutes of being idle, all data that have been created on the website will be automatically
deleted.

2. Open the text file named Data_Insert 1. Execute the following commands by copying the contents of
the file and pasting it to the query section of the website then click Run. The commands that have been
executed will automatically insert the data that will be used for this exercise. See the table below.

ID Model_Name Brand Price PurchaseDate


1 Galaxy S10 Samsung 25,000.00 2020-01-12
2 Galaxy S20 Samsung 55,000.00 2020-01-18
3 Galaxy Note10 Samsung 40,000.00 2020-01-22
4 Galaxy A51 Samsung 21,000.00 2020-01-31
5 iPhone X Apple 50,000.00 2020-02-03
6 iPhone 11 Apple 70,000.00 2020-02-07

04 Laboratory Exercise 1 *Property of STI


Page 1 of 4
IT2003

7 iPhone 6s Apple 20,000.00 2020-02-10


8 iPhone 8 Apple 30,000.00 2020-02-21
9 Y8 Huawei 16,000.00 2020-03-10
10 P30 Huawei 45,000.00 2020-03-12
11 Y9 Huawei 24,000.00 2020-03-14
12 P40 Huawei 50,000.00 2020-03-19
13 Redmi 9 Xiaomi 10,000.00 2020-03-21
14 Redmi K30 Xiaomi 25,000.00 2020-04-03
15 Mi Note 10 Xiaomi 15,000.00 2020-04-21
16 BlackShark Xiaomi 30,000.00 2020-04-20
17 iPhone 11 Apple 70,000.00 2020-04-22
18 iPhone 11 Apple 70,000.00 2020-05-03
19 Galaxy S20 Samsung 55,000.00 2020-05-10
20 Galaxy S10 Samsung 25,000.00 2020-05-12
21 Galaxy Note10 Samsung 40,000.00 2020-05-14
22 iPhone 8 Apple 30,000.00 2020-05-21
23 BlackShark 3 Xiaomi 30,000.00 2020-05-22
24 P40 Huawei 45,000.00 2020-05-08
25 iPhone X Apple 70,000.00 2020-05-10

Table 1. Purchase_Items

3. Using the ROLLUP operator, write queries that will compute the total amount of the items
purchased per brand and its grand total. See the output below.

Output:

4. Using the ROLLUP operator, write queries that will compute all the item purchased per brand
and per month, as well as its grand total of all purchased items in all date.

04 Laboratory Exercise 1 *Property of STI


Page 2 of 4
IT2003

Output:

5. Using the CUBE operator, write queries that will do the following:

5.1. Display the item purchased per brand and its month. Compute the grand total per
brand, and the grand total for all items.
5.2. Display the total amount of all items purchased each month. See the output below.

04 Laboratory Exercise 1 *Property of STI


Page 3 of 4
IT2003

Output:

GRADING RUBRIC:
CRITERIA PERFORMANCE INDICATORS POINTS
Correctness The code produces the expected result. 30
Logic The code meets the specifications of the problem. 30
Efficiency The code is concise without sacrificing correctness and logic. 20
Syntax The code adheres to the rules of the database management system. 20
Total 100

04 Laboratory Exercise 1 *Property of STI


Page 4 of 4

You might also like