There are a ton of resources available on the internet to build SQL competency so we have decided to take a different approach for this SQL overview.
For the next 25 days, you will be serving as the newly hired Data Analyst for Basira and Co, An Afro fusion restaurant with a network of chains across Africa and you’ll be reporting to the Chief Growth Officer (CGO) Mrs Ahmadu.
Everyday, you’ll get analytical requests/tasks from her related to the SQL topic of the day. The goal for this is to make each lesson as practical and as relatable as possible.
HOW TO PRACTICE: Here is a link to our practice guide. We have already prepared the table schema in advance so all you need to do is plug that into DBFiddle.com and you are all set! The LinkedIn forum is a great way to share any comments or questions about the practice guide.
YOU’VE GOT MAIL!
Welcome to Basira and Co. Hope you had a smooth onboarding so far. We are really glad to have you as part of the team!
Right now I am working on an expansion strategy with the finance team and we’d like to know the countries our restaurants are currently operating in.
I know you are still getting better acquainted with our systems but I’d like to get this data by the end of the day.
Mrs Ahmadu (CGO)
SQL TOPIC OF THE DAY
SQL Syntax: The Building Blocks of Querying
Whether you’re just starting your SQL journey or looking to enhance your skills, understanding the syntax is crucial. SQL queries are composed of various clauses that allow you to interact with databases effectively. Let’s explore the key elements:
|– SELECT: Specify the columns you want to retrieve from a table.|
– FROM: Identify the source table(s) for your query.
– WHERE: Filter rows based on specific conditions.
– GROUP BY: Group rows to perform aggregate functions.
– HAVING: Filter grouped rows based on conditions.
– ORDER BY: Sort the result set.
– JOIN: Combine data from multiple tables.
– UNION: Merge results from two or more SELECT statements.
– LIMIT: Restrict the number of rows in the result.
Retrieving Data & Defining Data Sources
The SELECT clause is the workhorse of SQL, responsible for fetching specific data from a database. While the FROM clause specifies the source table(s) from which the data will be retrieved:
1. Selecting Columns
|SELECT column1, column2, …|
/*column1, column2, …: These are the columns you want to retrieve from the table.
table_name: This is the name of the table where the data is stored.*/
2. Wildcard Usage
/*The asterisk (*) is a wildcard that retrieves all columns from the specified table.*/
3. Alias for Clarity
|SELECT column1 AS alias_name|
/*An alias provides a more descriptive name for a column, making it easier to read and understand*/
Now we can write a script that can provide a solution for the CGO. (based on the dataset provided)
FEEDBACK FROM THE CGO
Great! Thanks for the list you shared.
I now have a better understanding of our current global presence.
Quick question, can you also provide the city list alongside the country names?
Mrs Ahmadu (CGO)