Let’s decompose a simple query and see what’s it consists of:
This particular query consist of 7 elements we could distinguish:
– SELECT — keyword that answers the question “what we are going to do with data?”.
– currency — here we list column names that we are going to select, we must separate them by commas. It is possible to retrieve all columns, in this way asterisk “*” must be put here instead of column names.
– FROM — obligatory keyword pointing to the data array we will look into.
– cct — name of the database table that we are querying. It is not necessary to use a database table here, it could be another SQL statement as well.
– WHERE — non-obligatory keyword marks the start of conditions. We have to use it almost every time for better performance. It looks like a filter in most cases, in spite of this it is not a filter. We could put any statement after this keyword and the SQL engine will define is it true or false for each returned row.
– country = ‘Italy’ — is a part of the condition statement. Here it is a column country we will use for filtering source data, equation operator =, and a string constant ‘Italy’. If we need several conditions in one query we have to use AND/OR after each.
– ; — marks the end of the query.
SQL is a powerful tool. It could be used for getting data as well as for changing it and updating table records in the database. Anyway, people who make reports, dashboards, and other types of visualization use SELECT statements more often than others. If you are interested in learning SQL, please look at this page https://www.w3schools.com/sql/default.asp