Skip to content

Commit 3a01ecc

Browse files
authored
Update 1543. Fix Product Name Format.sql
1 parent fc0b375 commit 3a01ecc

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

Easy/1543. Fix Product Name Format.sql

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
Table: Sales
2-
3-
+--------------+---------+
4-
| Column Name | Type |
5-
+--------------+---------+
6-
| sale_id | int |
7-
| product_name | varchar |
8-
| sale_date | date |
9-
+--------------+---------+
10-
sale_id is the primary key for this table.
11-
Each row of this table contains the product name and the date it was sold.
1+
-- Table: Sales
2+
3+
-- +--------------+---------+
4+
-- | Column Name | Type |
5+
-- +--------------+---------+
6+
-- | sale_id | int |
7+
-- | product_name | varchar |
8+
-- | sale_date | date |
9+
-- +--------------+---------+
10+
-- sale_id is the primary key for this table.
11+
-- Each row of this table contains the product name and the date it was sold.
1212

1313

14-
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.
14+
-- 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.
1515

16-
Write an SQL query to report
16+
-- Write an SQL query to report
1717

18-
product_name in lowercase without leading or trailing white spaces.
19-
sale_date in the format ('YYYY-MM').
20-
total the number of times the product was sold in this month.
21-
Return the result table ordered by product_name in ascending order. In case of a tie, order it by sale_date in ascending order.
18+
-- product_name in lowercase without leading or trailing white spaces.
19+
-- sale_date in the format ('YYYY-MM').
20+
-- total the number of times the product was sold in this month.
21+
-- Return the result table ordered by product_name in ascending order. In case of a tie, order it by sale_date in ascending order.
2222

23-
The query result format is in the following example.
23+
-- The query result format is in the following example.
2424

2525

2626

27-
Example 1:
28-
29-
Input:
30-
Sales table:
31-
+---------+--------------+------------+
32-
| sale_id | product_name | sale_date |
33-
+---------+--------------+------------+
34-
| 1 | LCPHONE | 2000-01-16 |
35-
| 2 | LCPhone | 2000-01-17 |
36-
| 3 | LcPhOnE | 2000-02-18 |
37-
| 4 | LCKeyCHAiN | 2000-02-19 |
38-
| 5 | LCKeyChain | 2000-02-28 |
39-
| 6 | Matryoshka | 2000-03-31 |
40-
+---------+--------------+------------+
41-
Output:
42-
+--------------+-----------+-------+
43-
| product_name | sale_date | total |
44-
+--------------+-----------+-------+
45-
| lckeychain | 2000-02 | 2 |
46-
| lcphone | 2000-01 | 2 |
47-
| lcphone | 2000-02 | 1 |
48-
| matryoshka | 2000-03 | 1 |
49-
+--------------+-----------+-------+
50-
Explanation:
51-
In January, 2 LcPhones were sold. Please note that the product names are not case sensitive and may contain spaces.
52-
In February, 2 LCKeychains and 1 LCPhone were sold.
53-
In March, one matryoshka was sold.
27+
-- Example 1:
28+
29+
-- Input:
30+
-- Sales table:
31+
-- +---------+--------------+------------+
32+
-- | sale_id | product_name | sale_date |
33+
-- +---------+--------------+------------+
34+
-- | 1 | LCPHONE | 2000-01-16 |
35+
-- | 2 | LCPhone | 2000-01-17 |
36+
-- | 3 | LcPhOnE | 2000-02-18 |
37+
-- | 4 | LCKeyCHAiN | 2000-02-19 |
38+
-- | 5 | LCKeyChain | 2000-02-28 |
39+
-- | 6 | Matryoshka | 2000-03-31 |
40+
-- +---------+--------------+------------+
41+
-- Output:
42+
-- +--------------+-----------+-------+
43+
-- | product_name | sale_date | total |
44+
-- +--------------+-----------+-------+
45+
-- | lckeychain | 2000-02 | 2 |
46+
-- | lcphone | 2000-01 | 2 |
47+
-- | lcphone | 2000-02 | 1 |
48+
-- | matryoshka | 2000-03 | 1 |
49+
-- +--------------+-----------+-------+
50+
-- Explanation:
51+
-- In January, 2 LcPhones were sold. Please note that the product names are not case sensitive and may contain spaces.
52+
-- In February, 2 LCKeychains and 1 LCPhone were sold.
53+
-- In March, one matryoshka was sold.
5454

5555

5656

0 commit comments

Comments
 (0)