CREATE TABLE Studenti (nr_mat NUMBER(6), nume VARCHAR(20), grupa VARCHAR(6), medie_admit FLOAT, bursa FLOAT);

SELECT * FROM Studenti;

INSERT INTO Studenti VALUES (898989, 'VladTP', '331CA', 9.89, 0);
INSERT INTO Studenti VALUES (1, 'Gigel Frumosu', '336CA', 7.89, 0);
INSERT INTO Studenti VALUES (2, 'Tudorica', '333CA', 9.89, 0);
INSERT INTO Studenti VALUES (3, 'Stana de Piatra', '331CA', 6.73, 0);
INSERT INTO Studenti VALUES (738393, 'Romeo Fantastik', '335CA', 2.5, 0);

INSERT INTO Studenti VALUES (&nr_mat, &numele, &grupa, &medie_admit, 0);

accept fond prompt 'Fond burse: '

DEFINE suma = '(SELECT SUM(medie_admit) FROM Studenti)';
DEFINE pct = '(&fond / &suma)';

UPDATE Studenti SET bursa=(&pct * medie_admit);

SELECT * FROM Studenti;

UPDATE Studenti SET bursa=0 WHERE medie_admit < 7;

DEFINE suma = '(SELECT SUM(medie_admit) FROM Studenti WHERE medie_admit >= 7)';
DEFINE pct = '(&fond / &suma)';

UPDATE Studenti SET bursa=(&pct * medie_admit) WHERE medie_admit >= 7;

SELECT * FROM Studenti;
