This 100 Days of SQL challenge is a structured approach to learn and improve your SQL skills. The challenge involves daily practice exercises and challenges over the course of 100 days. It is a great way for beginners and experienced SQL users to enhance their knowledge and proficiency with the language. By committing to this challenge, individuals can make significant progress in their SQL skills.
Note: This challenge is structured and generated by ChatGPT.
Day 01 – What is SQL?
SQL (Structured Query Language) is a programming language used to manage and manipulate data stored in relational database management systems (RDBMS). It is a standard language used by most relational database systems, including Oracle, Microsoft SQL Server, MySQL, PostgreSQL, and many others.
SQL allows you to create, modify, and delete database tables, as well as insert, update, and delete data within those tables. You can also retrieve data from tables using SQL queries, which can be used to filter, sort, and aggregate data based on specific criteria.
SQL is divided into two main categories: Data Definition Language (DDL) and Data Manipulation Language (DML). DDL is used to create, alter, and delete database objects such as tables, indexes, and constraints. DML is used to insert, update, delete, and query data within those objects.
SQL is a powerful and flexible language that can handle large amounts of data and complex queries. It is widely used in industries such as finance, healthcare, e-commerce, and many others for managing and analyzing data.
The SQL SELECT statement is used to retrieve data from one or more tables in a database. It is the most commonly used statement in SQL and is used to filter, sort, and group data based on specific criteria. The basic syntax of a SELECT statement is:
SELECT column1, column2, ... FROM table_name;
In this syntax, column1, column2, etc. are the names of the columns that you want to retrieve data from, and table_name is the name of the table that you want to retrieve data from.
Here’s an example of a SELECT statement that retrieves all columns from a table named “employees”:
SELECT * FROM employees;
In this example, the * (asterisk) symbol is used to retrieve all columns from the “employees” table.
You can also specify conditions to filter the data that is retrieved by using the WHERE clause. Here’s an example:
SELECT * FROM employees WHERE department = 'Sales';
In this example, the WHERE clause is used to retrieve only the rows from the “employees” table where the department column equals ‘Sales’.
You can also use the ORDER BY clause to sort the data that is retrieved. Here’s an example:
SELECT * FROM employees ORDER BY last_name ASC;
In this example, the ORDER BY clause is used to sort the data in ascending order by the “last_name” column.
In addition to filtering and sorting data, you can also use the SELECT statement to perform calculations on the data using aggregate functions such as SUM, COUNT, AVG, MIN, and MAX. Here’s an example:
SELECT department, AVG(salary) as avg_salary FROM employees GROUP BY department;
In this example, the AVG function is used to calculate the average salary for each department in the “employees” table, and the GROUP BY clause is used to group the data by department.
These are just a few examples of how the SQL SELECT statement can be used to retrieve and manipulate data in a database. With the SELECT statement, you can create complex queries to retrieve and analyze data based on specific criteria.