Introducing notebooks
Notebooks are a widely used industry tool that make it easy to do data work.
A notebook is a document for keeping and running code, including SQL, R & Python. This introductory project will focus on SQL.
Making use of cells
Notebooks are made up of cells. There are several types of cells, including text, code & SQL cells.
We will focus on SQL and text cells in this introduction.
The text you're reading now is all part of a text cell. We've used it to write this guide for you.
Text cells are used to make the notebook readable, to add explanations, comments and document important details. This makes it easier for other people to read the notebook.
SQL cells
As this is a SQL project we'll focus on SQL cells. SQL cells are how you will connect to databases (and sometimes even text files 🤯) to run your SQL code. All the credentials are already set up so you can focus on writing SQL.
When you run a SQL cell it can return a DataFrame. A DataFrame is like a temporary table holding the results of the SQL query. Each DataFrame has a name, which can be edited. We run tests on the Dataframe to see if your query is correct.
-- Here's a SQL cell. Have a play around with this query and try running it/ editing the code.
select *
from sales.orders
Adding and removing cells
Cells can be added, removed and reordered to keep the notebook organised.
Try adding a new SQL cell beneath this cell. Note it has a default name df
.
Submitting your solution
SQL projects will normally ask you to output 1+ DataFrames as the solution to the problems.
When you hit "Submit Project" your notebook is run from start to finish and a number of tests are run to check if the output DataFrames are correct.
A few tips 🤓:
- If there is an error anywhere in your notebook the tests won't run. You can hit "Run All" to check if any cells throw any errors. (You'll see a "Run error" in the top right hand corner of any problematic cells)
- Names of DataFrames, columns etc need to match exactly as these are what are used in the tests.
- Pay attention to sorting and ordering of data, as some projects have requirements around this.
If any of the tests fail you will get a feedback message helping you understand where you may have gone wrong.
Help tackling the project
You will need to come up with your own solution to the project. You are free to use any approach you think makes sense, it simply needs to meet the requirements so it passes the tests.
We offer support with tackling a project.
- Resources: Links to learning content that is particularly relevant to the project.
- Guides: Provide a best practice approach to solving the project. It includes specific detailed hints on how you could tackle key steps.
- Solution: Completely stuck? View a model solution to see how the author solved it.
Now its your turn to complete this project!
We've added an incorrect answer below. Try hitting submit with the wrong answer to see how the feedback works.
Given it a try? Now try updating to filter on order_id
10 and submit again.
Now you know everything to be successful with Notebook SQL projects. Good luck!
-- Here's an example query solution.
-- Try submitting the project without changing anything to see the feedback message.
-- Now update the query to filter on order_id 10 to get it correct.
select customer_id
from sales.orders
where order_id = 9 -- replace with 10 and submit to complete the project.
select customer_id
from sales.orders
where order_id = 10