WGU c170 Database Applications
Labs With complete Solution
Course
WGU c170
1. Create a Student Table
Task: Create a Student table with:
StudentID — integer, primary key
FirstName — up to 40 characters
LastName — up to 40 characters
Email — up to 100 characters
Major — up to 60 characters
Complete solution:
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(40),
LastName VARCHAR(40),
Email VARCHAR(100),
Major VARCHAR(60)
);
2. Insert Student Records
Task: Insert three students into the Student table.
Complete solution:
INSERT INTO Student (StudentID, FirstName, LastName, Email, Major)
VALUES
(101, 'John', 'Smith', '', 'Information Technology'),
(102, 'Mary', 'Jones', '', 'Computer Science'),
, (103, 'David', 'Brown', '', 'Data Analytics');
3. Retrieve All Students
Task: Display every column and row from Student.
Complete solution:
SELECT *
FROM Student;
4. Select Specific Columns
Task: Display only students' first names, last names, and majors.
Complete solution:
SELECT FirstName, LastName, Major
FROM Student;
5. Filter Students
Task: Display students majoring in Computer Science.
Complete solution:
SELECT *
FROM Student
WHERE Major = 'Computer Science';
6. Sort Query Results
Task: Display students alphabetically by last name.
Complete solution:
SELECT *
FROM Student
Labs With complete Solution
Course
WGU c170
1. Create a Student Table
Task: Create a Student table with:
StudentID — integer, primary key
FirstName — up to 40 characters
LastName — up to 40 characters
Email — up to 100 characters
Major — up to 60 characters
Complete solution:
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(40),
LastName VARCHAR(40),
Email VARCHAR(100),
Major VARCHAR(60)
);
2. Insert Student Records
Task: Insert three students into the Student table.
Complete solution:
INSERT INTO Student (StudentID, FirstName, LastName, Email, Major)
VALUES
(101, 'John', 'Smith', '', 'Information Technology'),
(102, 'Mary', 'Jones', '', 'Computer Science'),
, (103, 'David', 'Brown', '', 'Data Analytics');
3. Retrieve All Students
Task: Display every column and row from Student.
Complete solution:
SELECT *
FROM Student;
4. Select Specific Columns
Task: Display only students' first names, last names, and majors.
Complete solution:
SELECT FirstName, LastName, Major
FROM Student;
5. Filter Students
Task: Display students majoring in Computer Science.
Complete solution:
SELECT *
FROM Student
WHERE Major = 'Computer Science';
6. Sort Query Results
Task: Display students alphabetically by last name.
Complete solution:
SELECT *
FROM Student