Комментарии:
Here is the source code for this video:
select version()
show server_version;
drop table HR_Employee
create table HR_Employee
(
emp_id int not null,
annual_salary numeric not null,
--a generated column is a table column
--that is "always generated" from some other column or columns
--the computation must produce the same datatype
hourly_rate numeric generated always as (annual_salary / 2080) stored
)
insert into HR_Employee(emp_id, annual_salary)
values
(1, 35000.00),
(2, 50000.00),
(3, 100000.00);
select *
from HR_Employee
select *
from HR_Employee
where hourly_rate > 20
update HR_Employee
set annual_salary = 55000
where emp_id = 2;
what if i wanted to compute the value based on other values in other columns
lets say that i have 2 entities test and semester
and the entity test has a foreign key semester_id and a regular column credit_score
and the entity semester also has credit_score which is the sum of all the credit_score of all the tests that are related to the semester.
how would i compute the credit_score for semester.