create table employees (emp_id varchar, emp_name varchar);
insert into booking values (‘b_1′,’1/1/2021′,100, ’emp_1′);
insert into booking values (‘b_2′,’1/1/2021′,200, ’emp_1′);
insert into booking values (‘b_3′,’1/3/2021′,300, ’emp_1′);
insert into booking values (‘b_8′,’1/4/2021′,1000, ’emp_2′);
insert into booking values (‘b_9′,’2/5/2021′,2000, ’emp_2′);
insert into employees values (’emp_1′,’Mohsin’);
insert into employees values (’emp_2′,’Jaskaran’);
with booking_info as
(
select b.*,
row_number () over (partition by b.emp_id order by booking_date) as rn
from booking b
),
min_max_info as
(
select emp_id,min(rn) as min_rn, max(rn) as max_rn
from booking_info
group by emp_id
),
min_date as
(
select bi.emp_id, bi.booking_date, amount
from booking_info bi
join min_max_info mmi_min on bi.emp_id = mmi_min.emp_id and bi.rn = mmi_min.min_rn
),
max_date as
(
select bi.emp_id, bi.booking_date, amount
from booking_info bi
join min_max_info mmi_max on bi.emp_id = mmi_max.emp_id and bi.rn = mmi_max.max_rn
)
select
e.emp_name,
min_date.booking_date as first_booking_date,
max_date.booking_date as last_booking_date,
min_date.amount+max_date.amount as Total_booking_amount,
(min_date.amount+max_date.amount)/2 as avg_Sales_amount
from min_date
join max_date on min_date.emp_id = max_date.emp_id
join employees e on min_date.emp_id = e.emp_id
Output:
emp_name | first_booking_date | last_booking_date | total_booking_amount | avg_sales_amount
———-+——————–+——————-+———————-+——————
Mohsin | 2021-01-01 | 2021-01-03 | 400 | 200
Jaskaran | 2021-01-04 | 2021-02-05 | 3000 | 1500

Photo from Surendra


Table name
date
Month No
week no
size
2. Then keep adding size of each table to this table on daily basis
3.Then create a query that will find size of table now – size of table (recently added date row) in table created in step 1.
This will give you daily growth
4. For monty growth, find size of each table now – last record of previous month
Subscribe mt youtube channel for more
Web development
Web design
App design
Ui and ux design
Tutorials

into table dress
FIELDS TERMINATED by ‘,’
ENCLOSED by ‘”‘
lines terminated by ‘n’
IGNORE 1 ROWS;
into table dress
FIELDS TERMINATED by ‘,’
ENCLOSED by ‘”‘
lines terminated by ‘n’
IGNORE 1 ROWS;

Having this error can anyone help