0% found this document useful (0 votes)
11 views3 pages

SQL Final

The document outlines SQL commands for creating and managing two tables: EBILL and CLASS. It includes operations such as inserting data, altering tables to add new columns, updating records for billing amounts and due dates, and calculating total marks and results for students. Additionally, it provides queries to retrieve data based on specific conditions such as pass/fail status and percentage marks.

Uploaded by

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

SQL Final

The document outlines SQL commands for creating and managing two tables: EBILL and CLASS. It includes operations such as inserting data, altering tables to add new columns, updating records for billing amounts and due dates, and calculating total marks and results for students. Additionally, it provides queries to retrieve data based on specific conditions such as pass/fail status and percentage marks.

Uploaded by

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

CREATE TABLE EBILL(RR_NO VARCHAR2(10) , CUST_NAME VARCHAR2(10), BILLING_DATE DATE, UNITS NUMBER(4));

DESC EBILL;

INSERT INTO EBILL VALUES(‘EH102’,'SARAVANAN','2-FEB-22',150);


INSERT INTO EBILL VALUES(‘EH103’,'RAKESH','5-FEB-22',100);
INSERT INTO EBILL VALUES(‘EH104’,'SURESH','12-FEB-22',90);
INSERT INTO EBILL VALUES(‘EH105’,'VINODH','10-FEB-22',180);
INSERT INTO EBILL VALUES(‘EH106’,'SAMUEL','6-FEB-22',120);
INSERT INTO EBILL VALUES(‘EH107’,'KARAN','15-FEB-22',67);

ALTER TABLE EBILL ADD(BILL_AMT NUMBER(6,2),DUE_DATE DATE);

UPDATE EBILL SET BILL_AMT=50;


UPDATE EBILL SET BILL_AMT=50+UNITS*4.5 WHERE UNITS<=100;
UPDATE EBILL SET BILL_AMT=50+100*4.5 +(UNITS-100)*5.5 WHERE UNITS>100;

UPDATE EBILL SET DUE_DATE=BILLING_DATE+15;

SELECT * FROM EBILL;


CREATE TABLE CLASS(STUD_ID NUMBER(10) , STUD_NAME VARCHAR2(25), SUB1 NUMBER(3), SUB2 NUMBER(3),
SUB3 NUMBER(3),SUB4 NUMBER(3) SUB5 NUMBER(3), SUB6 NUMBER(3));

INSERT INTO CLASS VALUES (1412, 'KARAN', 60,30,45,45,36,49);


INSERT INTO CLASS VALUES (1403, 'SACHIN', 56,60,72,57,78,67);
INSERT INTO CLASS VALUES (1410, 'PRAKASH', 96,99,97,90,78,100);
INSERT INTO CLASS VALUES (1402, 'POOJA', 30,45,39,20,33,56);
INSERT INTO CLASS VALUES (1405, 'ASHWINI', 79,65,79,70,89,88);
INSERT INTO CLASS VALUES (1406, 'PRAJWAL', 100,90,100,89,90,100);
INSERT INTO CLASS VALUES (1407, 'ESHWAR', 100,100,100,98,99,100);

ALTER TABLE CLASS ADD(TOTAL NUMBER(5), PERC_MARKS NUMBER(6,2), RESULT VARCHAR2(10));

UPDATE CLASS SET TOTAL=SUB1+SUB2+SUB3+SUB4+SUB5+SUB6;


UPDATE CLASS SET PERC_MARKS =TOTAL/6.0;

UPDATE CLASS SET RESULT = ‘PASS’ WHERE (SUB1 >=35 AND SUB2 >=35 AND SUB3 >=35 AND SUB4 >=35 AND SUB5 >=35 AND
SUB6 >=35 );
UPDATE CLASS SET RESULT = ‘FAIL’ WHERE (SUB1 <35 OR SUB2 <35 OR SUB3 <35 OR SUB4 <35 OR SUB5<35 OR SUB6 <35 );

SELECT * FROM CLASS;


SELECT * FROM CLASS WHERE RESULT =’PASS’;
SELECT * FROM CLASS WHERE RESULT =’FAIL’;
SELECT COUNT( *) FROM CLASS WHERE RESULT =’PASS’;
SELECT COUNT(*) FROM CLASS WHERE RESULT =’FAIL’;

SELECT STUD_ID, STUD_NAME FROM CLASS;

SELECT * FROM CLASS WHERE PERC_MARKS > 60;


SELECT * FROM CLASS ORDER BY STUD_ID;

You might also like