0% found this document useful (0 votes)
17 views2 pages

SQL Proram 1

The document outlines the steps to create and manage an electricity billing system for five customers using SQL. It includes creating a table with specific fields, inserting records, modifying the table structure, calculating bill amounts based on unit consumption, and determining due dates. Finally, it provides SQL commands to display all generated bills.

Uploaded by

preethid222007
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)
17 views2 pages

SQL Proram 1

The document outlines the steps to create and manage an electricity billing system for five customers using SQL. It includes creating a table with specific fields, inserting records, modifying the table structure, calculating bill amounts based on unit consumption, and determining due dates. Finally, it provides SQL commands to display all generated bills.

Uploaded by

preethid222007
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/ 2

PROGRAM 1:

Generate the electricity bill for Five customer.


Create a table for house hold Electricity bill with the following fields.

Field Name Type

RR_NO VARCHAR2(10)

CUS_NAME VARCHAR2(15)

BILLING_DATE DATE

UNITS NUMBER(4)

Insert 5 records into the table.

1. Check the structure of table and note your observation.

2. Add two fields to the table.

a. BILL_AMT NUMBER(6,2)

b. DUE_DATE DATE

3. Compute the bill amount for each customer as per the following rules.

a. MIN_AMT Rs. 50

b. First 100 units Rs 4.50/Unit

c. >100 units Rs. 5.50/Unit

4. Compute due date as BILLING_DATE + 15 Days

5. List all the bills generated.


1. create the table EBILL using CREATE TABLE command.

CREATE TABLE EBILL(RR_NO VARCHAR2(10), CUS_NAME VARCHAR2(15), BILLING_DATE DATE, UNITS


NUMBER(4));

2. Insert 5 records into the table using INSERT commands

INSERT INTO EBILL VALUES ('EH 1003', 'ARUN KUMAR' ,'12-MAR-16',98);

INSERT INTO EBILL VALUES ('EH 2005', 'NAVEEN' ,'14-MAR-16',108);

INSERT INTO EBILL VALUES ('EH 2007','VARUN' ,'18-FEB-16',157);

INSERT INTO EBILL VALUES ('EH 3009', 'DAVID' ,'11-APR-16',77);

INSERT INTO EBILL VALUES ('EH 3010', 'JHON' ,'01-MAR-16',89);

3. Check thestructure of table and note your observation.

DESC EBILL;

4. Add two fields to the table.


a. BILL_AMT NUMBER(6,2)
b. DUE_DATE DATE

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

ALTER TABLE EBILL ADD(DUE_DATE DATE);

5. Compute the bill amount for each customer as per the following rules.
a. MIN_AMT Rs. 50
b. First 100 units Rs 4.50/Unit
c. >100 units Rs. 5.50/Unit

UPDATE EBILL SET BILL_AMT=50;

UPDATE EBILL SET BILL_AMT=100+UNITS *4.25 WHERE UNITS<=100;

UPDATE EBILL SET BILL_AMT=100+100 *4.25+(UNITS -100)*5 WHERE UNITS>100;

6. Compute due date as BILLING_DATE + 15 Days

UPDATE EBILL SET DUE_DATE=BILLING_DATE+15;

7. List all the bills generated.

SELECT * FROM EBILL;

You might also like