0% found this document useful (0 votes)
13 views6 pages

DBMS Assginment06

This document contains 15 SQL queries related to a Student table. The queries perform operations like adding a column, inserting data, aggregations, string functions, and date conversions on the Student table and related data.

Uploaded by

Unknown XYZ
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)
13 views6 pages

DBMS Assginment06

This document contains 15 SQL queries related to a Student table. The queries perform operations like adding a column, inserting data, aggregations, string functions, and date conversions on the Student table and related data.

Uploaded by

Unknown XYZ
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/ 6

Name – Pratibha Rana

Section – AJ 15
Univ. Roll no. – 2215001306

Lab Assignment – 6
1. Create a new column DoB in Student table. (Datatype will be date)
Alter table student add DoB date ;

2. Insert DoB for each Student in corresponding table using above


instance of Student table.
Update student SET DOB = '7-APR-95' WHERE SID = 234 ;

3. Find average of GPA round off to 2 decimal places.


Select round ( avg ( gpa ) ,2 ) from student ;

4. Find year of DoB of Student having less than 1000.


Select extract ( year from dob ) from Student where sizehs < 1000 ;

5. Compute Age of each student. (Hint: take difference between year of


sysdate and Student’s DoB)
Select extract ( year from sysdate ()) - extract ( year from dob ) from student ;
6. Display name of all Students in uppercase and name of college they
applied in lower case.
Select upper ( sname ) ,lower ( cname ) from student s , apply a where
s . sid = a . sid ;
7. Find fourth alphabet of each student. (Hint: use substring)
Select substr( sname , 4 , 1 ) from student ;

8. Find sID and sName of student whose sName has string length greater
than 3.
Select sid , sname from student where length ( sname ) > 3 ;

9 . Find floor, ceiling and truncate (to one decimal place) value of average
GPA.
Select FLOOR ( avg ( gpa )) ,ceil ( avg ( gpa )) ,TRUNCATE ( avg ( gpa
) ,1 ) from student ;

10.Display details of all students whose sID is even.


Select * from student where mod ( sid , 2 ) = 0 ;

11.Compute Square Root of 900 and 247.


SELECT sqrt ( 900 ), sqrt ( power ( 24 , 7 )) from dual ;
12.Consider the string “Peter Piper picked a peck of pickled peppers. A
peck of pickled peppers Peter Piper picked. If Peter Piper picked a
peck of pickled peppers, Where the peck of pickled peppers Peter
Piper picked?” Find 6th occurrence of string ‘pick’. (Hint: use INSTR)
Select instr ( 'Peter Piper picked a peck of pickled peppers. A peck of pickled peppers
Peter Piper picked. If Peter Piper picked a peck of pickled peppers, Where the peck of
pickled peppers Peter Piper picked?' , 'pick' , 1 , 6 ) as pick from dual ;

13.Consider String ‘Satya Nadella’ replace this using the key (Hint: use
translate) (a d e l N S t y) -> (1 2 3 4 5 6 7 8)
Select TRANSLATE ( 'Satya Nadella' , 'adelNSty' , '12345678' ) from dual ;

14.Display sID, sname and DoB in this format ‘February 26, 2014’.
Select sid , sname , to_char ( dob , 'Monthdd,yyyy' ) from student ;

15.Convert the text ’26/02/2014’ to date.


Select to_date ( '26/02/2014' , 'DD/MM/YYYY' ) from dual ;
16.Compute on which date is next Saturday and last day of this month?
Select sysdate , last_day ( sysdate ) , next_day ( sysdate , 'Saturday' )
from dual ;

You might also like