I have the following table that is the “Class” table:
I want the “class_size” column to be generated automatically based on the other two columns.
I have tried the following SQL statement, but it doesn’t work:
update Class set class_size=totalSize where totalSize,Cnum in (Select class_number as Cnum ,count(student_id) as totalSize from Class group by class_number) and class_number = Cnum;
I really appreciate it if someone can help me with this problem, as I tried many different statements and still I cannot get it right.