SQL2: Your First SQL Query
SQL Data Types, SQL Queries, and SQL Statements, and some Interview Questions
“If you don’t know SQL, no sane company will hire you” - Mike West. If you don’t have a strong foundation in SQL, your dream of becoming a MLE/DS will stay a dream. SQL questions are the most common questions you get asked on your 2nd round of interviews.
Welcome to the big leagues. Many different vendors provide their own version of SQL. They are almost the same, with small differences here and there. Remember, if you don’t know SQL, you won’t get hired for any of these roles:
Data Scientist,
Data Analyst,
Machine Learning Engineer,
Data Engineer,
Quantitative Analyst.
Proof:
Here’s some more proof.
You should use this page as a handy reference guide. It will save you a lot of headache down the line.
Table of Contents:
SQL Data Types
SQL Queries
SQL Statements
SQL Queries
Basic SQL Statements
SELECT/ SELECT DISTINCT
MIN/MAX/AVG/SUM
COUNT
Exercises & Interview Questions
Exercises
Interview Questions
1 - SQL Data Types
There are many different vendors of SQL server providers. I’ve made a table that lists different categories for each of them, with the definition, and an example. Go over the chart so you have a ballpark idea, and you should be good to go here.
The information presented here comes from the official vendor’s websites.
T-SQL: Transact SQL’s official documentation
MySQL: MySQL’s official documentation
PostGreSQL: PostGreSQL’s official documentation
String Data Types: When working with string data types with a SQL database, all 3 vendors of SQL support the data types I’ve put in the below table.
Numeric Data Types:
When working with numeric data types with a SQL database, all 3 vendors of SQL support the data types I’ve put in the below table.
Date/DateTime Data Types:
When working with date/time data types with a SQL database, all 3 vendors of SQL support the data types I’ve put in the below table.
JSON Data Type:
Another popular data type you will use is JSON data type. This is basically like a Python dictionary.
Keep reading with a 7-day free trial
Subscribe to Data Science & Machine Learning 101 to keep reading this post and get 7 days of free access to the full post archives.