Examples
GAIA DR3 Determination of velocity dispersion in a star cluster
Retrieves 1,000 stars from the Hyades cluster using Gaia DR3 data with selection criteria: - Parallax 18-22 mas → distances ~45-55 parsecs (Hyades expected range) - Proper motion in RA: 80-100 mas/yr - Proper motion in Dec: -50 to -30 mas/yr Ensures stars share common motion characteristic of Hyades members. Results sorted by increasing G-band magnitude (brightest stars first). Expected queue time: 30 seconds
-- 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)
GAIA DR3 Distribution of blue stars in the direction of the galactic halo
Extracts 1,000 hot blue stars in the Milky Way's galactic halo using: - BP-RP color index < 0.5 (identifies blue, high-temperature stars) - Parallax between 0.1 and 1.0 mas (distances ~1-10 kpc, typical of halo) - Declination > 30° (northern sky) Results sorted by increasing G-band magnitude (brightest stars first). Expected queue time: 5 minutes
-- 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 Stars with the highest parallax (closest to Earth)
Retrieves the 20 stars with the highest parallax values (closest to Earth). Parallax greater than 10 mas roughly corresponds to distances within 100 parsecs. Results sorted in descending order of parallax (closest stars 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)
MPC SBN Check if an object is numbered
Checks whether a given object (e.g., 2010 HL23) is numbered. Returns a boolean value.
-- 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 Secondary designations for a primary designation
Retrieves all secondary designations for a primary designation. The current_identifications table contains all current identifications. If object A is linked to object B, the table contains entries for both A=A and A=B. Returns secondary designations when A is the primary designation. Note: Table contains both 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
Retrieves all secondary designations for a generic designation (not necessarily a primary designation). Uses a subquery when the primary designation is unknown to retrieve all designations associated with the same object. Note: Wrap with SELECT to_json(t) FROM(...) AS t; for JSON format output.
-- 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 Retrieve permid for a given object
Retrieves the permid (permanent identifier/number) for a given object. If an object is numbered, its number can be extracted from the numbered_identifications table. The query joins current_identifications to obtain the primary provisional designation, which is required to query numbered_identifications. Note: numbered_identifications can only be queried using the primary provisional designation (packed or unpacked).
-- 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
Retrieves all observations for a numbered object in MPC-1992 80-column format. For numbered objects, 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
Retrieves 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.
-- 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
Retrieves 100 highly reddish objects from the 2MASS Point Source Catalog (PSC) using the J-Ks color index. Identifies objects with (J-Ks) > 2.0, which may be due to high extinction (dust) or very cool temperatures (e.g., brown dwarfs). Ensures relatively bright sources with Ks-band magnitude < 15. Results sorted by descending J-Ks color (reddest objects 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)
DES DR2 Sample of 1000 bright stars
Sample of 1000 bright stars selecting magnitudes in g band with quality flags and star/galaxy classification (extended_class_coadd). FLAGS_[G,R,I,Z,Y] contains 8 flag bits with warnings about source extraction: 1 - aperture photometry biased by neighboring sources or >10% bad pixels 2 - object has been deblended (crowded regions like galaxy clusters) 4 - at least one object pixel is saturated EXTENDED_CLASS_COADD (star/galaxy classification): 0 - very likely a star (pure star sample) 1 - likely a star, contamination by galaxies expected (complete star sample) 2 - likely a galaxy, contamination by stars expected (complete galaxy sample) 3 - very likely a galaxy (pure galaxy sample) -99 - flag (no data) Reference: https://arxiv.org/pdf/2101.05765.pdf
-- 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 with i band magnitudes corrected by extinction (Schlegel+1998). Quality given by flags_i and extended_class_coadd. FLAGS_[G,R,I,Z,Y] contains 8 flag bits: 1 - aperture photometry biased by neighboring sources or >10% bad pixels 2 - object has been deblended (useful in crowded regions) 4 - at least one object pixel is saturated EXTENDED_CLASS_COADD (classification): 0 - very likely a star (pure star sample) 1 - likely a star, contamination by galaxies expected 2 - likely a galaxy, contamination by stars expected 3 - very likely a galaxy (pure galaxy sample) -99 - flag (no data) Reference: https://arxiv.org/pdf/2101.05765.pdf
-- 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 Checking star-galaxy classification by color-color diagram
Star-galaxy classification verification using a 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 WHERE 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
Color-Magnitude Diagram (CMD) of a pure sample of 1000 bright galaxies in r and i bands corrected by extinction (Schlegel+1998). Uses (r-i) color for CMD. FLAGS_[G,R,I,Z,Y] contains 8 flag bits: 1 - aperture photometry biased by neighboring sources or >10% bad pixels 2 - object has been deblended (crowded regions) 4 - at least one object pixel is saturated EXTENDED_CLASS_COADD (classification): 0 - very likely a star 1 - likely a star, contamination by galaxies expected 2 - likely a galaxy, contamination by stars expected 3 - very likely a galaxy (pure galaxy sample) -99 - flag (no data) Reference: https://arxiv.org/pdf/2101.05765.pdf
-- 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 Magnitude errors for mag_auto
Retrieves magnitude errors for mag_auto measurements in g, r, and i bands with quality flags and epoch information.
-- 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 Selecting stars in a box near Sculptor dwarf galaxy
Selects stars in a spatial box near the Sculptor dwarf galaxy with extinction- corrected magnitudes and calculated (g-r) color.
-- 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