Create the following table in your database with the following schema: Table: Sales | Column Name | Type | sale id I product_name | varchar | | sale_date | int I date +----- --+ sale_id is the primary key for this table. Each row of this table contains the product name and the date it was sold. Add the following data to your tables: Input: Sales table: +-------- I sale_id | product_name | sale_date I | LCPHONE | LCPhone | LcPhOnE | LCKEYCHAIN | LCKeyChain | Matryoshka | 1 | 2 | 2000-01-16 | | 2000-01-17 | | 2000-02-18 | | 2000-02-19 | | 2000-02-28 | | 2000-03-31 | | 4 Since table Sales was filled manually in the year 2000, product_name may contain leading and/or trailing white spaces, also they are case-insensitive. Write an SQL query to report • product_name in lowercase without leading or trailing white spaces. • sale_date in the format (YYYY-MM'). • total the number of times the product was sold in this month. Return the result table ordered by product_name in ascending order. In case of a tie, order it by sale_date in ascending order. Hint: you may need to use the following functions: • LOWER() • TRIM() • DATE_FORMATO The results should be: Output: I product_name | sale_date I total | | lckeychain | lcphone | lcphone | matryoshka | 2000-02 | 2000-01 | 2000-02 | 2000-03 | 2 | 2 1. | 1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write all the sql code (including create, insert and select), screenshot the output alongside the codes please.

Create the following table in your database with the following schema:
Table: Sales
| Column Name
I Туре
+----
| sale_id
I product_name
| sale date
| int
varchar|
I date
+-----
+----
sale id is the primary key for this table.
Each row of this table contains the product name and the date it was sold.
Add the following data to your tables:
Input:
Sales table:
+--
I sale idI product name | sale date
+--
| 1
| 2
| 3
| LCPHONE
| LCPhone
| LcPhOnE
| LCKeyCHAiN
| LCKeyChain
| Matryoshka
| 2000-01-16 |
| 2000-01-17 |
| 2000-02-18 |
| 2000-02-19 |
| 2000-02-28 |
| 2000-03-31 |
| 5
Since table Sales was filled manually in the year 2000, product_name may contain leading and/or
trailing white spaces, also they are case-insensitive.
Write an SQL query to report
• product_name in lowercase without leading or trailing white spaces.
• sale_date in the format ("YYYY-MM').
• total the number of times the product was sold in this month.
Return the result table ordered by product_name in ascending order. In case of a tie, order it by
sale_date in ascending order.
Hint: you may need to use the following functions:
• LOWER(O
• TRIM()
• DATE_FORMAT()
The results should be:
Output:
I product_name | sale_date | total |
+--
| lckeychain
| lcphone
| lcphone
| matryoshka
| 2000-02
| 2000-01
| 2000-02
| 2000-03
| 2
| 2
| 1
| 1
Transcribed Image Text:Create the following table in your database with the following schema: Table: Sales | Column Name I Туре +---- | sale_id I product_name | sale date | int varchar| I date +----- +---- sale id is the primary key for this table. Each row of this table contains the product name and the date it was sold. Add the following data to your tables: Input: Sales table: +-- I sale idI product name | sale date +-- | 1 | 2 | 3 | LCPHONE | LCPhone | LcPhOnE | LCKeyCHAiN | LCKeyChain | Matryoshka | 2000-01-16 | | 2000-01-17 | | 2000-02-18 | | 2000-02-19 | | 2000-02-28 | | 2000-03-31 | | 5 Since table Sales was filled manually in the year 2000, product_name may contain leading and/or trailing white spaces, also they are case-insensitive. Write an SQL query to report • product_name in lowercase without leading or trailing white spaces. • sale_date in the format ("YYYY-MM'). • total the number of times the product was sold in this month. Return the result table ordered by product_name in ascending order. In case of a tie, order it by sale_date in ascending order. Hint: you may need to use the following functions: • LOWER(O • TRIM() • DATE_FORMAT() The results should be: Output: I product_name | sale_date | total | +-- | lckeychain | lcphone | lcphone | matryoshka | 2000-02 | 2000-01 | 2000-02 | 2000-03 | 2 | 2 | 1 | 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY