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

Assignment SQL

The document outlines the schemas for two database tables: Student and Course, detailing their columns and data types. It also provides a series of SQL queries for fetching and manipulating data from the Student table, including operations like fetching names, removing spaces, and finding unique class values. The queries demonstrate various SQL functions such as UPPER, DISTINCT, SUBSTRING, and CONCAT.

Uploaded by

ihtshamali770
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)
6 views2 pages

Assignment SQL

The document outlines the schemas for two database tables: Student and Course, detailing their columns and data types. It also provides a series of SQL queries for fetching and manipulating data from the Student table, including operations like fetching names, removing spaces, and finding unique class values. The queries demonstrate various SQL functions such as UPPER, DISTINCT, SUBSTRING, and CONCAT.

Uploaded by

ihtshamali770
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

Assignment

Database Systems

Table Schemas

1. Student Table

Column Name | Data Type | Description


STUDENT_ID | INT | Primary Key
FIRST_NAME | VARCHAR(50) | Student's first name
LAST_NAME | VARCHAR(50) | Student's last name
CLASS | VARCHAR(20) | Class name or section
ADMISSION_DATE | DATE | Date of admission

2. Course Table

Column Name | Data Type | Description


COURSE_ID | INT | Primary Key
COURSE_NAME | VARCHAR(100) | Name of the course
DEPARTMENT | VARCHAR(50) | Department offering course
CREDITS | INT | Number of credits

SQL Queries

Fetch FIRST_NAME with alias


SELECT FIRST_NAME AS STUDENT_NAME
FROM Student;

Fetch FIRST_NAME in upper case


SELECT UPPER(FIRST_NAME)
FROM Student;

Fetch unique CLASS values


SELECT DISTINCT CLASS
FROM Student;

Print first three characters of FIRST_NAME


SELECT SUBSTRING(FIRST_NAME, 1, 3)
FROM Student;

Find position of 'a' in FIRST_NAME


SELECT INSTR(FIRST_NAME, 'a')
FROM Student
WHERE FIRST_NAME = 'any name';

Print FIRST_NAME after removing trailing spaces


SELECT RTRIM(FIRST_NAME)
FROM Student;

Print CLASS after removing leading spaces


SELECT LTRIM(CLASS)
FROM Student;

Fetch unique CLASS values and print lengths


SELECT DISTINCT CLASS, LENGTH(CLASS) AS Class_Length
FROM Student;

Print FIRST_NAME and LAST_NAME as COMPLETE_NAME


SELECT CONCAT(FIRST_NAME, ' ', LAST_NAME) AS COMPLETE_NAME
FROM Student;

Print details where FIRST_NAME contains 'a'


SELECT *
FROM Student
WHERE FIRST_NAME LIKE '%a%';

You might also like