SQL 101

Photo by Anthony Martino on Unsplash

The most efficient way to get our data is by having a direct access to the database. And fortunately, the most analyzed data is still in structured format so far. This post will assume that we have a database and a client app installed in our laptop. We can choose to install an open source database like Postgre or MySQL. As client app, we can use DBeaver or the equivalent. After connecting the client app to rhe database, we can start to roll. There are three commands as baseline pattern for a query. Keep reading to know more!

Select

This command will call the columns we want to see in the result. Usually, one table has many columns but we only need to display some of them to fulfill the requirements. An advanced version of query can produce a processed result from certain columns.

From

This part is used to call the table name. By default, all tables usually sits under one schema called public. In huge databases, tables can be grouped under different schema to help analysts find the correct tables.

Where

Basic command to include or exclude some part of the table. Most of the time, we need to have lots of this filter to make our query run more efficiently.

Closing

Those are 3 basic commands to start getting our data. Having this in mind can help us to get the raw data from our database. Later on we can add another command to aggregate some columns to get some metrics.

See you in the next post!

Leave a comment