The select list has column names or expressions involving columns.
SQL expressions are not very different from those of other programming languages.
SELECT TOP 10 source_id, SQRT(POWER(pmdec_error,2)+POWER(pmra_error,2)) AS pm_errTot FROM gaiadr1.tgas_source
The value literals are as usual:
The usual arithmetic, comparison, and logical operators work as expected:
Here’s a list of ADQL functions:
Note that all names in SQL (column names, table names, etc) are case-insensitive (i.e., VAR and var denote the same thing). You can force case-sensitivity (and use SQL reserved words as identifiers) by putting the identifiers in double quotes (that’s called delimited identifiers). Don’t do that if you can help it, since the full rules for how delimited identifiers interact with normal ones are difficult and confusing.
Also note how I used AS to rename a column. You can use the names assigned in this way in, e.g., ORDER BY:
SELECT TOP 10 source_id, SQRT(POWER(pmdec_error,2)+POWER(pmra_error,2)) AS pm_errTot FROM gaiadr1.tgas_source ORDER BY pm_errTot
To select all columns, use *
SELECT TOP 10 * FROM gaiadr1.tgas_source
Use COUNT(*) to figure out how many items there are.
SELECT count(*) AS numEntries FROM gaiadr1.tgas_source
COUNT is what’s called an aggregate function in SQL: A function taking a set of values and returning a single value. The other aggregate functions in ADQL are (all these take an expression as argument; count is special with its asterisk):
Select the source id, position, proper motion in arcsec/yr and mag g for the 20 fastest stars in tgas_source.