Data Science & Machine Learning 101

Data Science & Machine Learning 101

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
SQL2: Your First SQL Query

SQL2: Your First SQL Query

SQL Data Types, SQL Queries, and SQL Statements, and some Interview Questions

BowTied_Raptor's avatar
BowTied_Raptor
Jan 12, 2023
∙ Paid
18

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
SQL2: Your First SQL Query
1
Share

“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:

As a Data Professional, you live or die by your SQL skills
As a Data Professional, you live or die by your SQL skills.

Here’s some more proof.

Job Posting for a MLE today.  See the SQL there.  You'll be tested on it.
Job Posting for a MLE today. See the SQL there. You’ll be tested on it.

You should use this page as a handy reference guide. It will save you a lot of headache down the line.

Table of Contents:

  1. SQL Data Types

  2. SQL Queries

    1. SQL Statements

    2. SQL Queries

  3. Basic SQL Statements

    1. SELECT/ SELECT DISTINCT

    2. MIN/MAX/AVG/SUM

    3. COUNT

  4. Exercises & Interview Questions

    1. Exercises

    2. 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.

TSQL, MySQL, and PostGreSQL support CHAR(), VARCHAR(), and TEXT
TSQL, MySQL, and PostGreSQL support all of these

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.

T-SQL, MySQL, and PostGres support INT, NUMERIC, and FLOAT(x)
TSQL, MySQL, and PostGreSQL support all of these

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.

MSSQL, MySQL, and PostGreSQL support DATE, TIME, DATETIME, and YEAR data types
TSQL, MySQL, and PostGreSQL support all of these

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.

Already a paid subscriber? Sign in
© 2025 BowTied_Raptor
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share