Obtaining objects and it's Lephare redshift, we need to JOIN two tables with a two column identifier. We restrict the search to a box in the sky and magnitude in 'r' lower than 20.:
SELECT Obj.alpha_j2000, Obj.delta_j2000, Obj.mag_auto, Obj.mag_err_auto, Obj.class_star, Obj.flags, Obj.mask_flags, lephare.* FROM jplus.MagABDualObj obj, jplus.PhotoZLephare lephare WHERE obj.TILE_ID = lephare.TILE_ID AND obj.NUMBER = lephare.NUMBER AND obj.mag_auto[jplus::rSDSS] < 20.0 AND CONTAINS(POINT('', Obj.alpha_j2000, Obj.delta_j2000), BOX('', 125, 30, .49, .49)) = 1
Obtaining the catalogue in magnitudes of a tile image by its identifier (64840 in the example):
SELECT * FROM jplus.MagABSingleObj WHERE TILE_ID = 64840
Obtaining the catalogue in magnitudes of a known object by its identifier (number 10 and image 64840 in the example):
SELECT * FROM jplus.MagABSingleObj WHERE TILE_ID = 64840 AND number = 10
Obtaining the catalogue in f(nu) fluxes of a tile image by its name, filtering objects with problems in its detection:
SELECT i.zpt, m.* FROM jplus.FNuSingleObj m, jplus.TileImage i WHERE i.tile_id = m.tile_id AND i.name = '1000001-JPLUS-02623-v202006_zSDSS_swp' AND (FLAGS = 0 OR FLAGS = 2048)
Obtaining the catalogue object in magnitudes in each filter of a reference tile image by its identifier, selecting only objects with gSDSS more than a magnitude brighter than rSDSS:
SELECT * FROM jplus.MagABDualObj WHERE TILE_ID = 64840 AND MAG_AUTO[jplus::gSDSS] - MAG_AUTO[jplus::rSDSS] > 1
Obtaining the number of objects per magnitude ordering by magnitude:
SELECT ROUND(MAG_AUTO[jplus::rSDSS], 0) AS MAG, COUNT(*) FROM jplus.MagABDualObj GROUP BY MAG ORDER BY MAG
Querying all columns and limiting the number of results, up to 50 rows, filtering images by right ascension:
SELECT TOP 50 * FROM jplus.TileImage WHERE ra > 116.0 AND ra < 116.5
Selecting image by filter using an enumeration to identify the filter:
SELECT * FROM jplus.TileImage WHERE filter_id = jplus::rSDSS
Joining tables and using geometric functions to do a cone search:
SELECT m.alpha_j2000, m.delta_j2000, m.flux_auto, m.class_star, i.name, i.tile_id FROM jplus.FNuDualObj m, jplus.TileImage i WHERE m.tile_id = i.tile_id AND CONTAINS(POINT('', m.alpha_j2000, m.delta_j2000), CIRCLE('', 7.8574, 5.67881, .005)) = 1