Job ID | Phase | Owner | Public | Description | Quote (sec.) | Available until | Start time | Exec Time | Query | Error | Output format | End time | Language | Catalogue | Rows found | Maximum rows | Run | Actions |
---|

Query syntax **OK**.

The Astronomical Data Query Language (ADQL) is the language used by the International Virtual Observatory Alliance (IVOA) to represent astronomy queries posted to VO services.

ADQL is based on the Structured Query Language (SQL), especially on SQL 92. Only *SELECT* sentences are allowed,
to express the maximum rows to return SQL 92 specifies the keyword *TOP*
followed by a number after the initial SELECT keyword.

ADQL predefines a list of mathematics and geometric functions. Geometric functions that accepts figures as a string uses the string format specified at the TAP protocol
in section '6 Use of STC-S in TAP (informative)'. For the coordinate system only **Spherical** coordinates in the frames
**FK5**, **GALACTIC**, and **ICRS** are supported. Note: unlike ADQL specifies, empty string assumes ICRS as the default coordinate system.

Obtaining all records and all the columns from the table *qabc03*:

SELECT * FROM quiescentgalaxies.qabc03

Obtaining all sources identifier from the table *qabc03*:

SELECT galaxy_id FROM quiescentgalaxies.qabc03

Aliases are used to give a database table, or a column in a table, a temporary name. Basically aliases are created to make column names more readable.

Renaming a column as *sources_number*:

SELECT COUNT(galaxy_id) AS sources_number FROM quiescentgalaxies.qabc03

Use the **TOP** instruction to limit the number of records to display.

Obtaining the first 100 records of the query in the table *qabc03*:

SELECT TOP 100 * FROM quiescentgalaxies.qabc03

Use the **ORDER BY** instruction to sort records in ascending (ASC) or descending (DESC).

Obtaining the 100 images with higher Stellar mass from the table *qabc03*:

SELECT TOP 100 * FROM quiescentgalaxies.qabc03 ORDER BY mstar ASC

As an extension to ADQL it is possible to use square brackets to access array elements of columns defined as arrays. First element of the array is at position 1. This allow, for example, store together all the fluxes or magnitudes measured in different filters for a position in the sky (see also section *6: Using enumerations*).

An extension to ADQL is the definition of *Enumerations*, it is a form of assign a set of names to a range of numbers. Writing a enumeration in a query is done by
writing the enumeration name, the symbol *::* and the item name of the enumeration that we want to use.
That is equivalent to write the associated number of the item and it is useful when accessing an concrete element in a array column or using it as a constant.

Use constraints to filter records according to logical expressions. In an ADQL query, the constraints are gathered in the WHERE part of the query.

Use the different operators **=** (equal), **<>** (not equal), **<** (less than), **>** (greater than), **<=** (less and equal than) and **>=** (greater and equal than) to compare values.

Obtaining the objects whose Stellar mass is less than 1.5 solMass:

SELECT * FROM quiescentgalaxies.qabc03 WHERE mstar < 1.5

Use the **IN** operator to determine whether a value is within a given set. You can reverse the operation of the IN operator by adding to the **NOT** operator.

Obtaining the objects with the identifiers 81421100765, 81421101074 and 81421101630:

SELECT * FROM quiescentgalaxies.qabc03 WHERE galaxy_id IN (81421100765, 81421101074, 81421101630)

Use the **BETWEEN** operator to determine whether a value is within a given interval.

Obtaining the objects whose Stellar mass is between 1.5 and 1.6 solMass:

SELECT * FROM quiescentgalaxies.qabc03 WHERE mstar BETWEEN 1.5 AND 1.6

Use the **LIKE** operator to execute partial comparisons. The wild card % replaces any string of characters, including the empty string. The underscore replaces exactly one character. You can reverse the operation of the LIKE operator by adding to the **NOT** operator.

Use **AND** operator to obtain records if both the first condition AND the second condition are true.

Obtaining the objects whose Stellar mass is less than 16 1.6 solMass and photoredshift less than 0.3:

SELECT * FROM quiescentgalaxies.qabc03 WHERE mstar < 1.6 AND z < 0.3

Use **OR** operator to obtain records if the first condition is true, the second condition is true or both are true.

Obtaining the objects whose Stellar mass is less than 16 1.6 solMass or photoredshift is less than 0.3:

SELECT * FROM quiescentgalaxies.qabc03 WHERE mstar < 1.6 OR z < 0.3

Use mathematical operations: **+**, **-**, ***** and **/** to compute columns. Obtaining the objects with a difference of more than 1 magnitude between filters rSDSS and gSDSS in magnitude auto:

SQL aggregate functions return a single value, calculated from values in a column.

Use **AVG(column_name)** function to obtain the average value in a column for a group of data lines. This function applies only to numeric data.

Obtaining the average value of the Stellar mass of all the objects:

SELECT AVG(mstar) FROM quiescentgalaxies.qabc03

Use **COUNT(column_name)** function to obtain a count of rows from a reference column values if it is not NULL.

Obtaining the total number of sources:

SELECT COUNT(galaxy_id) FROM quiescentgalaxies.qabc03

Use **SUM(column_name)** function to obtain the sum of values in a column for a group of data lines. This function applies only to numeric data.

Use **MAX(column_name)** function to obtain the largest value of a column for a group of data lines.

Obtaining the object with a largest stellar mass:

SELECT MAX(mstar) FROM quiescentgalaxies.qabc03

Use **MIN(column_name)** function to obtain the smallest value of a column for a group of data lines.

Obtaining the object with a smallest stellar mass:

SELECT MIN(mstar) FROM quiescentgalaxies.qabc03

Use **GROUP BY** statement in conjunction with the aggregate functions to group the result-set by one or more columns.

Obtaining the number of objects per stellar mass (rounding the stellar mass):

SELECT ROUND(mstar, 0) AS MAG, COUNT(*) FROM quiescentgalaxies.qabc03 GROUP BY mstar

Other functions like arithmetical functions, trigonometric functions, geometrical functions, conversion functions, ... are also available. Please, see *Functions* section to know more
about them.

*Note:* at the moment the geometric functions are partially supported, 'contains', 'distance' and 'area' are only implemented for basic figures.
*This is a work in progress!*.

Obtaining all objects using both methods qabc03 and qabasti:

SELECT qabc03.galaxy_id as galaxy_id, qabc03.*, qabasti.* FROM quiescentgalaxies.qabc03 AS qabc03, quiescentgalaxies.qabasti AS qabasti WHERE qabc03.galaxy_id = qabasti.galaxy_id

Tables: Most used

Please, click on the table, you want to obtain more information.

Please, click on the table, you want to obtain more information.

Functions

- ABS
- ACOS
- ARC_DISTANCE
- AREA
- ASIN
- ATAN
- ATAN2
- bit_and
- bit_or
- BOX
- CEILING
- CIRCLE
- CONTAINS
- COORD1
- COORD2
- COORDSYS
- corr
- COS
- covar_samp
- DEGREES
- DISTANCE
- EXP
- fLambdaToFNu
- FLOOR
- fNuFluxToJansky
- fNuFluxToMagAB
- fNuToFLambda
- INTERSECTS
- janskyToFNuFlux
- LOG
- LOG10
- magABToFNuFlux
- MOD
- PI
- POINT
- POLYGON
- POWER
- RADIANS
- RAND
- REGION
- REGR_INTERCEPT
- REGR_R2
- REGR_SLOPE
- ROUND
- SIN
- SQRT
- STDDEV
- string_agg
- TAN
- TRUNCATE
- VARIANCE

Please, click on the function, you want to obtain more information.

Enumerations

Please, click on the enumeration, you want to obtain more information.