This topic requires writing an UPDATE statement,
Increase the grades of all girls with a score below 75 by 5%;
Table Structure:
Please write the SQL statement that defines the table structure here. For example:
CREATE TABLE `stu` (
`sno` char(4) NOT NULL,
`sname` char(8) NOT NULL,
`sex` tinyint(1) DEFAULT NULL,
`mno` char(2) DEFAULT NULL,
`birdate` datetime DEFAULT NULL,
`memo` text,
PRIMARY KEY (`sno`)
);
CREATE TABLE `sc` (
`sno` char(4) NOT NULL,
`cno` char(4) NOT NULL,
`grade` decimal(6,1) DEFAULT NULL,
PRIMARY KEY (`sno`,`cno`),
CONSTRAINT `fk_sc_sno` FOREIGN KEY (`sno`) REFERENCES `stu` (`sno`)
)
table sample
Please give a table sample corresponding to the above table structure here. For example
Stu table:
sc table:
Sample output:
For example:
The sc table after modifying the girls' grades is as follows:
Code length limit 16 KB
Time limit 400 ms
DatabaseMySQL
update sc
set grade = grade*1.05
where grade < 75 and sno in (
select sno
from stu
where sex = 0
)