Skip to main content
Creating a SQL Exercise

How to create a SQL activity using CodeHS Create

Sara Jenis avatar
Written by Sara Jenis
Updated over 3 months ago
Banner: Free feature

You can make you own autograded SQL problems in CodeHS Create. There are only a few steps to writing a good SQL program, and you can see a demo in the video below!

Create an assignment from Create page or Assignments page

Step 1: Create a SQL Exercise

  • Click Create in the left hand navigation to go to the Create app

  • Click Create New Assignment

  • Choose Coding Exercise > select a SQL Program Type

  • Fill in assignment details: title, description, and starter code

Step 2: Add Data and Solution Code through Advanced Settings

  • Click '...' next to the assignment > click Edit

  • Click on Advanced Settings (bottom left)

  • Click the SQL Setup Code Tab

  • Add your data. Note: Make sure to add the Table Names into SQL Tables

  • Click on the Code Tab

  • Enter your Starter Code and Solution Code

SQL Setup Code

You can use this sample code to help create tables and add data:


CREATE TABLE Name (id, first_name, last_name, house);
INSERT into Name values ("1", "Harry", "Potter", "1");
INSERT into Name values ("2", "Ron", "Weasley", "1");
INSERT into Name values ("3", "Hermione", "Granger", "1");
INSERT into Name values ("4", "Severus", "Snape", "4");



CREATE TABLE House (house_name, house_id);
INSERT into House values ("Gryffindor", "1");
INSERT into House values ("Ravenclaw", "2");
INSERT into House values ("Hufflepuff", "3");
INSERT into House values ("Slytherin", "4");


Still have questions? Contact our team at hello@codehs.com to learn more!

Did this answer your question?