0% found this document useful (0 votes)
15 views

Students Program

Uploaded by

Sneha S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Students Program

Uploaded by

Sneha S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

STUDENTS PROGRAM

PROGRAM:
-- create a table
CREATE TABLE students (
rno INTEGER PRIMARY KEY,
name TEXT NOT NULL,
phy INTEGER,che INTEGER,bio INTEGER,tam INTEGER,eng
INTEGER
);

-- insert some values


INSERT INTO students VALUES (1, 'Ryan',24,46,72,49,91);
INSERT INTO students VALUES (2, 'Joanna',50,89,52,25,87);
INSERT INTO students VALUES (3, 'sneha',85,86,94,92,81);
INSERT INTO students VALUES (4, 'roja',56,61,55,29,78);
INSERT INTO students VALUES (5, 'nandini',5,9,9,20,8);
--alteringtable
ALTER TABLE students ADD total INTEGER;
ALTER TABLE students ADD avg INTEGER;
ALTER TABLE students ADD grade VARCHAR(20);
UPDATE students SET total=phy+che+bio+tam+eng;
UPDATE students SET avg=total/5;
UPDATE students SET grade="good" WHERE avg>50 AND
avg<=100;
UPDATE students SET grade="average" WHERE avg>0 AND
avg<=50;
-- fetch some values
SELECT name,rno, avg from students where avg=(SELECT
max(avg) from students);

SELECT * FROM students WHERE name like 's%';

SELECT * FROM students WHERE avg>=80 and avg<=90;

SELECT name FROM students WHERE name like '_o%';


SELECT rno,name FROM students ORDER BY rno DESC;

SELECT rno,name FROM students WHERE avg<40;

OUTPUT:

You might also like