Examples

DES DR2 Sample of 1000 bright stars

SAMPLE OF 1000 BRIGHT STARS Selecting magnitudes of 1000 bright stars in g band with quality given by flags_g and star/galaxy classification given by extended_class_coadd FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process, in order of increasing concern. For instance: 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster) 4 at least one object pixel is saturated EXTENDED_CLASS_COADD (classification of objects as stars or galaxies): 0 - very likely a star (pure sample of stars) 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars) 2 - likely a galaxy, but a contamination of stars is expected) (more complete sample of galaxies) 3 - very likely a galaxy (pure sample of galaxies) -99 - flag (no data) The stars were observed at least in one image (nepochs_g >= 1). See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.

-- SAMPLE OF 1000 BRIGHT STARS
-- Selecting magnitudes of 1000 bright stars in g band
-- with quality given by flags_g and star/galaxy classification given by extended_class_coadd
-- FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process, in order of increasing concern. For instance:
-- 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture
-- 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster)
-- 4 at least one object pixel is saturated
-- EXTENDED_CLASS_COADD (classification of objects as stars or galaxies):
-- 0 - very likely a star (pure sample of stars)
-- 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars)
-- 2 - likely a galaxy, but a contamination of stars is expected) (more complete sample of galaxies)
-- 3 - very likely a galaxy (pure sample of galaxies)
-- -99 - flag (no data)
-- The stars were observed at least in one image (nepochs_g >= 1).
-- See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.

SELECT top 1000 coadd_object_id, ra, dec, wavg_mag_psf_g, flags_g, extended_class_coadd, nepochs_g
FROM des_dr2.main
WHERE ABS(extended_class_coadd) < 2
AND flags_g < 4
AND wavg_mag_psf_g < 20
AND nepochs_g >= 1

DES DR2 Pure sample of 1000 bright galaxies in i band

PURE SAMPLE OF 1000 BRIGHT GALAXIES IN I BAND Selecting i magnitudes of 1000 bright galaxies corrected by extinction (Schlegel+1998) with quality given by flags_i and star/galaxy classification given by extended_class_coadd. FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process: 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster) 4 at least one object pixel is saturated EXTENDED_CLASS_COADD (classification of objects as stars or galaxies): 0 - very likely a star (pure sample of stars) 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars) 2 - likely a galaxy, but a contamination of stars is expected (more complete sample of galaxies) 3 - very likely a galaxy (pure sample of galaxies) -99 - flag (no data) The galaxies were observed at least in one image (nepochs_i >= 1). See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.

-- PURE SAMPLE OF 1000 BRIGHT GALAXIES IN I BAND
-- Selecting i magnitudes of 1000 bright galaxies corrected by extinction (Schlegel+1998)
-- with quality given by flags_i and star/galaxy classification given by extended_class_coadd.
-- FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process:
-- 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture
-- 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster)
-- 4 at least one object pixel is saturated
-- EXTENDED_CLASS_COADD (classification of objects as stars or galaxies):
-- 0 - very likely a star (pure sample of stars)
-- 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars)
-- 2 - likely a galaxy, but a contamination of stars is expected (more complete sample of galaxies)
-- 3 - very likely a galaxy (pure sample of galaxies)
-- -99 - flag (no data)
-- The galaxies were observed at least in one image (nepochs_i >= 1).
-- See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.

SELECT top 1000 coadd_object_id, ra, dec, mag_auto_i_dered, flags_i, extended_class_coadd, nepochs_i
FROM des_dr2.main
WHERE ABS(extended_class_coadd) > 2
AND flags_i < 4
AND mag_auto_i_dered < 21
AND nepochs_i >= 1

DES DR2 Magnitude errors for mag_auto

Magnitude errors for mag_auto

-- MAGNITUDE ERRORS FOR MAG_AUTO

SELECT top 1000 mag_auto_g, magerr_auto_g,
mag_auto_r, magerr_auto_r,
mag_auto_i, magerr_auto_i,
flags_g, flags_r, flags_i,
nepochs_g, nepochs_r, nepochs_i
FROM des_dr2.main
WHERE flags_g < 4
AND flags_r < 4
AND flags_i < 4
AND nepochs_g >= 1
AND nepochs_r >= 1
AND nepochs_i >= 1

DES DR2 Checking star-galaxy classification by color-color diagram

Checking star-galaxy classification by color-color diagram with a pure sample of bright stars

-- CHECKING STAR-GALAXY CLASSIFICATION BY COLOR-COLOR DIAGRAM WITH A PURE SAMPLE OF BRIGHT STARS

SELECT top 1000 coadd_object_id, ra, dec, wavg_mag_psf_g_dered, wavg_mag_psf_r_dered, wavg_mag_psf_i_dered, wavg_mag_psf_g_dered-wavg_mag_psf_r_dered as gr_color, wavg_mag_psf_r_dered-wavg_mag_psf_i_dered as ri_color
FROM des_dr2.main
AND ABS(extended_class_coadd) < 1
AND flags_g < 4
AND flags_r < 4
AND flags_i < 4
AND ABS(wavg_mag_psf_g_dered) < 22.
AND ABS(wavg_mag_psf_r_dered) < 22.
AND ABS(wavg_mag_psf_i_dered) < 22.

DES DR2 CMD of a pure sample of 1000 bright galaxies in i band

CMD OF A PURE SAMPLE OF 1000 BRIGHT GALAXIES IN I BAND Selecting magnitudes of a sample of 1000 bright galaxies in r and i band corrected by extinction (Schlegel+1998) with quality given by flags_i and star/galaxy classification given by extended_class_coadd. FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process: 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster) 4 at least one object pixel is saturated EXTENDED_CLASS_COADD (classification of objects as stars or galaxies): 0 - very likely a star (pure sample of stars) 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars) 2 - likely a galaxy, but a contamination of stars is expected (more complete sample of galaxies) 3 - very likely a galaxy (pure sample of galaxies) -99 - flag (no data) The galaxies were observed at least in one image (nepochs_i >= 1). (r-i) color is calculated in order to plot a CMD. See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.

-- CMD OF A PURE SAMPLE OF 1000 BRIGHT GALAXIES IN I BAND
-- Selecting magnitudes of a sample of 1000 bright galaxies in r and i band corrected by extinction (Schlegel+1998)
-- with quality given by flags_i and star/galaxy classification given by extended_class_coadd.
-- FLAGS_[G,R,I,Z,Y] contains 8 flag bits with basic warnings about the source extraction process:
-- 1 aperture photometry is likely to be biased by neighboring sources or by more than 10% of bad pixels in any aperture
-- 2 the object has been deblended (you would want to keep this on regions that are a bit crowded, like a galaxy cluster)
-- 4 at least one object pixel is saturated
-- EXTENDED_CLASS_COADD (classification of objects as stars or galaxies):
-- 0 - very likely a star (pure sample of stars)
-- 1 - likely a star, but a contamination of galaxies is expected (more complete sample of stars)
-- 2 - likely a galaxy, but a contamination of stars is expected (more complete sample of galaxies)
-- 3 - very likely a galaxy (pure sample of galaxies)
-- -99 - flag (no data)
-- The galaxies were observed at least in one image (nepochs_i >= 1).
-- See DR2 paper (https://arxiv.org/pdf/2101.05765.pdf) for a complete description of columns.
-- (r-i) color is calculated in order to plot a CMD.

SELECT top 1000 coadd_object_id, ra, dec, mag_auto_r_dered, mag_auto_i_dered, flags_r, flags_i, extended_class_coadd, nepochs_i,
mag_auto_r_dered - mag_auto_i_dered as ri_color
FROM des_dr2.main
WHERE ABS(extended_class_coadd) > 2
AND flags_i < 4
AND flags_r < 4
AND mag_auto_i_dered < 21
AND nepochs_r >= 1
AND nepochs_i >= 1

DES DR2 Selecting stars in a box near Sculptor dwarf galaxy

Selecting stars in a box near Sculptor dwarf galaxy

-- SELECTING STARS IN A BOX NEAR SCULPTOR DWARF GALAXY!

SELECT top 100 coadd_object_id, ra, dec, mag_auto_g_dered, mag_auto_r_dered, mag_auto_g_dered - mag_auto_r_dered as gr_dered
FROM des_dr2.main
WHERE (ra > 15.0183 - 0.02)
AND (ra < 15.0183 + 0.02)
AND (dec > -33.719 - 0.02)
AND (dec < -33.719 + 0.02)
AND ABS(extended_class_coadd) < 2
AND flags_g < 4
AND flags_r < 4

MPC SBN Secondary designations for a primary designation

Retrieve all the secondary designations for a generic designation. The current_identifications table contains all the current identifications for the objects in the database. If an object A has been linked to an object B, the current_identifications table contains two entries: one for A=A and another one for A=B. This query returns all the secondary designations for object A, when A is the primary designation. Note: the current_identifications table contains both the packed and unpacked designations.

-- SECONDARY DESIGNATIONS FOR A PRIMARY DESIGNATION
-- The current_identifications table contains all the current identifications for the objects in the database.
-- If an object A has been linked to an object B, the current_identifications table contains two entries: one for A=A and another one for A=B.
-- This query returns all the secondary designations for object A, when A is the primary designation.
-- Note: the current_identifications table contains both the packed and unpacked designations.

SELECT unpacked_primary_provisional_designation, unpacked_secondary_provisional_designation
FROM mpc_sbn.current_identifications
WHERE unpacked_primary_provisional_designation = '2015 AC2'

MPC SBN Secondary designations for a generic designation

Retrieve all the secondary designations for a generic designation (not necessarily a primary designation). If the user doesn't know the primary designation, this query retrieves all the designations associated to the same object using a subquery. Note: to obtain the result in JSON format, wrap the query with SELECT to_json(t) FROM(...) AS t;

-- SECONDARY DESIGNATIONS FOR A GENERIC DESIGNATION
-- If the user doesn't know the primary designation, this query retrieves all the designations associated to the same object.

SELECT unpacked_primary_provisional_designation, unpacked_secondary_provisional_designation
FROM mpc_sbn.current_identifications
WHERE unpacked_primary_provisional_designation = (
    SELECT unpacked_primary_provisional_designation
    FROM mpc_sbn.current_identifications
    WHERE unpacked_secondary_provisional_designation = '2010 HL23'
)

MPC SBN Check if an object is numbered

Check whether an object is numbered. This query checks whether the object 2010 HL23 is numbered and returns a boolean.

-- CHECK IF AN OBJECT IS NUMBERED
-- This query checks whether the object 2010 HL23 is numbered and returns a boolean.

SELECT numbered
FROM mpc_sbn.current_identifications
WHERE unpacked_secondary_provisional_designation = '2010 HL23'

MPC SBN Retrieve permid for a given object

Retrieve the permid (permanent identifier/number) for a given object. If an object is numbered, and you want to look-up its number (permid) based on the unpacked_secondary_provisional_designation, the number (permid) can be extracted from the numbered_identifications table. Note: numbered_identifications table can only be queried using the primary provisional designation (packed or unpacked) and the primary provisional designation can be obtained with a join query with the current_identifications table.

-- RETRIEVE PERMID FOR A GIVEN OBJECT
-- If an object is numbered, look-up its number (permid) based on the unpacked_secondary_provisional_designation.
-- The numbered_identifications table can only be queried using the primary provisional designation.

SELECT permid
FROM mpc_sbn.numbered_identifications ni 
JOIN mpc_sbn.current_identifications ci
ON ni.unpacked_primary_provisional_designation = ci.unpacked_secondary_provisional_designation
WHERE ci.unpacked_primary_provisional_designation = (
    SELECT unpacked_primary_provisional_designation
    FROM mpc_sbn.current_identifications
    WHERE unpacked_secondary_provisional_designation = '2010 HL23'
)

MPC SBN Observations for a numbered object

Retrieve all the observations for a numbered object. This query returns all the MPC-1992 80-column format observations for the numbered object 123456. Note: if an object is numbered, the permid field is populated with the unpacked number.

-- ALL OBSERVATIONS FOR A NUMBERED OBJECT
-- Returns all the MPC-1992 80-column format observations for the numbered object 123456.
-- Note: if an object is numbered, the permid field is populated with the unpacked number.

SELECT obs80 
FROM mpc_sbn.obs_sbn 
WHERE permid = '123456'

MPC SBN Observations for an unnumbered object

Retrieve all the observations for an unnumbered object. If the object is unnumbered, it might be the result of a linkage, so this query joins the current_identifications table with the obs_sbn table to retrieve all the observations.

-- ALL OBSERVATIONS FOR AN UNNUMBERED OBJECT
-- If the object is unnumbered, it might be the result of a linkage.
-- This query joins current_identifications with obs_sbn to retrieve all observations.

SELECT obs80 
FROM mpc_sbn.obs_sbn AS o 
JOIN mpc_sbn.current_identifications AS ci
ON o.provid = ci.unpacked_secondary_provisional_designation 
WHERE ci.unpacked_secondary_provisional_designation IN (
    SELECT unpacked_secondary_provisional_designation
    FROM mpc_sbn.current_identifications
    WHERE unpacked_primary_provisional_designation = (
        SELECT unpacked_primary_provisional_designation
        FROM mpc_sbn.current_identifications
        WHERE unpacked_secondary_provisional_designation = '2010 HL23'
    )
)

2MASS Identify highly reddish objects

This ADQL query retrieves 100 highly reddish objects from the 2MASS Point Source Catalog (PSC), using the J-Ks color index to identify: -Objects with (J-Ks) > 2.0, which may be due to high extinction (dust) or very cool temperatures (e.g., brown dwarfs). -Ks-band magnitude < 15, ensuring the selection of relatively bright sources. Results are sorted by descending J-Ks color, so the reddest objects appear first.

-- Queue 5 minutes
-- ADQL
-- Selects 100 highly reddish objects based on J-Ks color index  
SELECT TOP 100  
    ra,               -- Right Ascension  
    decl,             -- Declination  
    j_m,              -- J-band magnitude (1.2 μm)  
    h_m,              -- H-band magnitude (1.6 μm)  
    k_m,              -- Ks-band magnitude (2.2 μm)  
    (j_m - k_m) AS color_jk  -- J-Ks color index, indicating extinction or low temperature  
FROM twomass.psc  
WHERE (j_m - k_m) > 2.0  -- Selects very red objects, possibly due to high extinction or cool temperatures  
AND k_m < 15             -- Limits to relatively bright objects in the Ks band  
ORDER BY color_jk DESC;   -- Sorts by J-Ks color in descending order (reddest objects first)

GAIA DR3 Stars with the highest parallax (closest to Earth)

This ADQL query retrieves the 20 stars with the highest parallax values from the Gaia DR3 catalog, meaning they are the closest to Earth. It selects the right ascension (ra), declination (dec), G-band mean magnitude (phot_g_mean_mag), and parallax, filtering for stars with a parallax greater than 10 milliarcseconds (mas) (which roughly corresponds to distances within 100 parsecs). The results are sorted in descending order of parallax, ensuring that the closest stars appear first.

-- Selects the 20 stars with the highest parallax (closest to Earth)
-- queue 30 seconds
SELECT TOP 20 
    ra,                -- Right Ascension
    dec,               -- Declination
    phot_g_mean_mag,   -- Mean G-band magnitude
    parallax           -- Parallax in milliarcseconds
FROM gaia_dr3.source
WHERE parallax > 10    -- Filters stars with parallax greater than 10 mas (~closer than 100 pc)
ORDER BY parallax DESC; -- Sorts by parallax in descending order (closest stars first)

GAIA DR3 Distribution of blue stars in the direction of the galactic halo

This ADQL query extracts 1,000 hot blue stars in the Milky Way's galactic halo from the Gaia DR3 catalog. The selection is based on: -BP-RP color index < 0.5, identifying blue, high-temperature stars. -Parallax between 0.1 and 1.0 mas, filtering stars at distances between ~1 and 10 kpc, typical of the halo. Declination (Dec) > 30°, restricting results to the northern sky. Results are sorted by increasing G-band magnitude, meaning the brightest stars appear first.

-- Selects 1000 hot blue stars in the Milky Way halo
-- Queue 5 minutes
-- ADQL
SELECT TOP 1000  
    ra,                -- Right Ascension (J2000)  
    dec,               -- Declination (J2000)  
    phot_g_mean_mag,   -- Mean G-band magnitude  
    bp_rp,             -- Color index (BP-RP), used to identify blue stars  
    parallax           -- Parallax in milliarcseconds (mas), used for distance filtering  
FROM gaia_dr3.source  
WHERE bp_rp < 0.5      -- Selects blue stars (hotter temperatures)  
AND parallax BETWEEN 0.1 AND 1.0  -- Restricts to distant stars (~1-10 kpc), likely in the halo  
AND dec > 30           -- Focuses on stars in the northern sky  
ORDER BY phot_g_mean_mag ASC;  -- Sorts by brightness, with the brightest stars first

GAIA DR3 Determination of velocity dispersion in a star cluster

This ADQL query retrieves 1,000 stars from the Hyades cluster using Gaia DR3 data. The selection criteria focus on: -Parallax (18–22 mas) → Filtering stars at distances ~45–55 parsecs, the expected range for Hyades. -Proper motion in RA (80–100 mas/yr) and Dec (-50 to -30 mas/yr) for Ensuring the stars share a common motion, characteristic of Hyades members. Results are sorted by increasing G-band magnitude, listing the brightest stars first.

-- Queue 30 seconds
-- ADQL
-- Selects 1000 stars from the Hyades cluster using parallax and proper motion  
SELECT TOP 1000  
    ra,                -- Right Ascension   
    dec,               -- Declination
    parallax,          -- Parallax in milliarcseconds, used for distance selection  
    pmra,              -- Proper motion in RA direction  
    pmdec,             -- Proper motion in Dec direction
    phot_g_mean_mag    -- Mean G-band magnitude  
FROM gaia_dr3.source  
WHERE parallax BETWEEN 18 AND 22  -- Selects stars at ~45-55 parsecs (Hyades cluster distance)  
AND pmra BETWEEN 80 AND 100       -- Proper motion range in RA, characteristic of Hyades stars  
AND pmdec BETWEEN -50 AND -30     -- Proper motion range in Dec, ensuring common motion  
ORDER BY phot_g_mean_mag ASC;      -- Sorts by brightness (brightest stars first)