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 POWER(10, alfa_fe) AS sol_ratio, SQRT(POWER(e_pmde, 2)+POWER(e_pmra, 2)) AS errTot FROM rave.dr2
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 POWER(10, alfa_Fe) AS sol_ratio, SQRT(e_pmde*e_pmde+e_pmra*e_pmra) AS errTot FROM rave.dr2 ORDER BY sol_ratio
To select all columns, use *
SELECT TOP 10 * FROM rave.dr3
Use COUNT(*) to figure out how many items there are.
SELECT count(*) AS numEntries FROM rave.dr3
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 absolute magnitude and the common name for the 20 stars with the greatest visual magnitude in the table fk6.part1 (in case you don’t remember: The absolute magnitude is M= 5 -5log π+ m with the parallax in arcsec π and the apparent magnitude m (check the units!).