https://www.youtube.com/watch?v=CQNxCYfCqzU&list=PLP8zk3fCtbPI6zpFi9-BENOuzCtUpMUwe&index=2

-- Create the Sales_ table
CREATE TABLE Sales_ (
    sale_id INT PRIMARY KEY,
    product_name VARCHAR(50),
    sale_date DATE
);

-- Insert data into the Sales_ table
INSERT INTO Sales_ (sale_id, product_name, sale_date)
VALUES 
    (1, '  LCPHONE', '2000-01-16'),
    (2, 'LCPhone', '2000-01-17'),
    (3, 'LcPhOnE', '2000-02-18'),
    (4, 'LCKeyCHAiN  ', '2000-02-19'),
    (5, 'LCKeyChain', '2000-02-28'),
    (6, ' Matryoshka', '2000-03-31');

Pasted image 20241201203832.png

UPPER()/LOWER()
DATE_FORMAT()
REPLACE()

select  
	LOWER(replace(product_name,' ','')) as Product_name,
    date_format(sale_date,'%Y-%m') as date,
    count(sale_id) as total
from sales_
group by LOWER(replace(product_name,' ','')),month(sale_date)
order by Product_name,sale_date