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

Aggregate and String Function

The document discusses implementing aggregate and string functions on a student table in Oracle. It creates a student table with fields for roll number, student name, and two marks. Values are inserted for two students. Aggregate functions like sum, min, max, average, and count are applied to the data. String functions such as concat, initcap, length, ascii, and lower are also demonstrated on the student data.

Uploaded by

atozdhiyanes
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Aggregate and String Function

The document discusses implementing aggregate and string functions on a student table in Oracle. It creates a student table with fields for roll number, student name, and two marks. Values are inserted for two students. Aggregate functions like sum, min, max, average, and count are applied to the data. String functions such as concat, initcap, length, ascii, and lower are also demonstrated on the student data.

Uploaded by

atozdhiyanes
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ex.

No: AGGREGATE & STRING FUNCTION


Date:

AIM:

To implement the aggregate and string function.

ALGORITHM:
Step 1:

Start the process.

Step 2:

Create student table with fields rollno, stuname, mark1,mark2.

Step 3:

Insert student table values and display the result.

Step 4:

Use the aggregate functions sum, max, min, average, count.

Step 5:

Use the string functions char, concat, Initcap, Length, ASCII.

Step 6:

Display the result.

Step 7:

Stop the process.


CREATE A TABLE:

SQL> create table student (rollno number (5), stuname varchar2 (20), mark1 number
(3), mark2 number (3));

Table created.

TABLE DESCRIPTION:

SQL> Desc student;

Name Null? Type

------------------------------- -------- ----------

ROLLNO NUMBER (5)

STUNAME VARCHAR2 (20)

MARK1 NUMBER (3)

MARK2 NUMBER (3)

INSERT VALUES

SQL> insert into student values (&rollno, '&stuname',& mark1,& mark2);

Enter value for rollno: 2436

Enter value for stuname: Ramji

Enter value for mark1: 97

Enter value for mark2: 98

Old 1: insert into student values (&rollno, '&stuname',& mark1,& mark2)

New 1: insert into student values (2436, 'Ramji',97,98)

1 row created.

SQL> /

Enter value for rollno: 2442

Enter value for stuname: Sakthi

Enter value for mark1: 95

Enter value for mark2: 94


Old 1: insert into student values (&rollno, '&stuname',& mark1,& mark2)

New 1: insert into student values (2442, 'Sakthi',95,94)

1 row created.

SELECT TABLE

SQL> select * from student;

ROLLNO STUNAME MARK1 MARK2

--------- -------------------- ----------- -----------

2436 Ramji 97 98

2442 Sakthi 95 94

AGGREGATE FUNCTION IN STUDENT TABLE

SQL> select sum (mark1) from student;

SUM (MARK1)

-------------------

192

SQL> select min (mark1) from student;

MIN (MARK1)

--------------------

95

SQL> select max(mark2) from student;

MAX (MARK2)

--------------------

98

SQL> select count(*) from student where mark2 >=90;

COUNT (*)

---------------

2
SQL> select avg(mark2) from student;

AVG (MARK2)

--------------------

96

STRING FUNCTION IN STUDENT TABLE

SQL> select concat('Rama','chandran') from dual;

CONCAT('RAMA','CHANDRAN')

------------------------------------------------

Ramachandran

SQL> select initcap (stuname) from student;

INITCAP(STUNAME)

-----------------------------

Sakthi

SQL> select length(stuname) from student;

LENGTH(STUNAME)

-------------------------------

SQL> select ascii('R') from dual;

ASCII('R')

--------------

82

SQL> select lower('MCA') from dual;

LOW

--------

mca

You might also like