This week I learned several things about SQL; but first let me tell you that I joined a team in charge of managing data internally in the company, working in a team with these characteristics is quite beneficial since I’ve shown that I’ve several areas of opportunity in SQL, so with the help of the team and the data at my disposal, I can't only practice and improve my SQL skills, but all the projects I do will have a use for the company.

Photo by Sunder Muthukumaran on Unsplash

Getting into the matter I tell you that I learned how to add "harcoded" values ​​(that is, their value will be the same until someone changes them manually) with the help of the reserved word "VALUES", the structure to do this is the following :

SELECT *
FROM (VALUES(value1),
(value2),
(value3),
(value4),
(value5),
(value6),
(value7),
(value8),
(value9),
(value10)

) AS hardcoded_table(column_name1)

This way of adding an entire table with manually set values ​​is quite useful for tasks that require handling data that for some reason you don't want to save to the database (maybe you just don't want to or you don't have write permissions in the database).

Another concept that I learned was to use the reserved word "WITH" to keep data that you later use to select only part of it or simply keep it apart from its original source (one reason for this is that the data does not exist in the database, that is, they are hardcoded or you made a transformation to them that you will later use), the structure with which you can keep more than one table with this word is the following:

WITH hardcoded_table (column_name1) AS (
SELECT *
FROM (VALUES(value1),
(value2),
(value3),
(value4),
(value5),
(value6),
(value7),
(value8),
(value9),
(value10)

) AS hardcoded_table(column_name1)
),

table_name2(column1, column2) AS (
SELECT *
SUM(column0) Total AS
FROM table_name2
)

The reason why I used this configuration that granted me to save two tables was to be able to do a JOIN to them that allowed me to obtain data that I later used to create two graphs.

I am very surprised how making these types of queries is to a certain extent easy once you understand the SQL syntax, in the same way, I think that SQL does all the processes in a brutally fast way, it makes sense to me why it is the standard of the industry when handling data.

Finally, I want to say that I learned how to use the "Metabase" platform, which seems to me to be a very important effort to be able to have high-quality dashboards, I really like that it is open source and that it competes against giants such as Tableau or Power BI who belongs to the industry giant Microsoft.

--

--

Data science & food engineer 👨‍💻

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store