The "select" data request can be used to obtain data from datasets available within your Spotzi Account. You can obtain either a single record or the entirety of your selected dataset. "Select" data requests can be made by adding a SELECT request to the "q" parameter.
A typical select query generally follows the structure below:
The above statement is divided into:
The first section of the select query:
States which columns the select statements needs to return. Using the * character allows you to retrieve all columns; you can also retrieve specific columns by naming them explicitly. For example:
The second section of the select query:
Specifies which dataset is being requested. The columns described in the first part of the query must exist within this dataset for this query to work.
The final — and optional — section of the select query:
This specifies which rows are being requested. All rows meeting the requirements of the WHERE statement will be returned.
Below you will find some example queries that can be used via the Spotzi Webservice. The table names and fields used in these examples must be available in the requested webservice account to display valid results.
The above statement returns all fields within the table "neighbourhood".
The above statement returns the neighbourhood_name and the population of the neighbourhood table.
The above statement returns a calculated percentage of male inhabitants in each neighbourhood.
The above statement returns a calculated percentage of the male inhabitants within all urban neighbourhoods.
The above statement uses the ORDER BY and LIMIT statements. The ORDER BY statement orders the result by the requested field; The LIMIT statement limits the number of these results.
For more information about SQL SELECT statements, please consult the SQL section of our help center or see the official PostgreSQL tutorial.