sqlbeginner10 minutes

Create a Simple Student Grades Table and Query

Build a beginner-level SQL project to create a basic data model for student grades. Define a table, insert sample data, and write a query to retrieve student names with their corresponding grades.

Challenge prompt

You are tasked with creating a simple data model to store student grades in a class. First, create a table named `StudentGrades` with the following columns: `StudentID` (integer, primary key), `StudentName` (text), and `Grade` (integer). Then, insert at least 5 students with their grades. Finally, write a query to select all students who scored 80 or above, showing their names and grades in ascending order by grade.

Guidance

  • Focus on defining the table with appropriate data types and a primary key.
  • Insert sample data for at least 5 students.
  • Write a SELECT query with a WHERE condition to filter grades >= 80 and ORDER BY grade ascending.

Hints

  • Use CREATE TABLE syntax with column definitions including INT and VARCHAR or TEXT.
  • INSERT INTO can be used multiple times to add student records.
  • Use SELECT with WHERE and ORDER BY clauses to retrieve filtered and sorted results.

Starter code

CREATE TABLE StudentGrades (
  StudentID INT PRIMARY KEY,
  StudentName TEXT,
  Grade INT
);

-- Insert sample data here

-- Write your SELECT query below

Expected output

StudentName | Grade ------------|------- Alice | 80 Bob | 85 Eve | 90

Core concepts

CREATE TABLEINSERT INTOSELECTWHERE clauseORDER BY clause

Challenge a Friend

Send this duel to someone else and see if they can solve it.