This post is all about data skills in SQL. Feel free to grab any dataset/SQL of your preference to try these out.
Table of Contents
Working With String Data
Working With Numeric Data
Working With Time/Date Data
Converting Data
Exercises/Interview Questions
I highly recommend going over the different types of data available in SQL, since this post is all about wrangling data.
You can also watch this video that gives you a quick gloss over the basic data types.
1 - Working With Strings Data
When we are working with string data, sometimes we are interested in manipulating them to something else. SQL gives us 2 types of function for messing around with strings:
String to Numeric value
String to String value
Remember, all of these run with the SELECT function, which means none of them will make any permanent changes to your database. Just meant for wrangling data.
Note: Unless you use ALTER TABLE… SET, this will not permanently alter your database.
1.1 String To Numeric Fns
To save you a bunch of time, I made a table that you can look at, to see what is available to you.
If you want to run these functions on a column, just swap out the strings in the example with the column names.
Example Below:
SELCT Length(my_col) as Len_of_my_col
FROM my_table
1.2 String To String Fns
Enjoy the time saving table below.
2 - Working With Numeric Data
There are plenty of functions that deal with handling numeric data. I’ve kicked out the useless ones that you’ll never use, or be quizzed about. AKA the only stuff that’s left is the useful bits.
2.1 Arithmetic Calculations
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.