Hi all, I hope this message finds you well!
I have a question regarding how to perform a particular type of query on the Rubin Science Platform (using the ADQL query window), and specifically the SSSource catalog. I would like my query to return one (or some set number) of rows for each of the ~4.4 million Solar System objects in the catalog; e.g., one row for each ssObjectId (including multiple columns, such as heliocentricDist and the heliocentric velocities, among others). This seems like a straightforward query, but for some reason I am having trouble getting it to work, and I am not sure whether this is due to my admittedly very limited SQL experience, or due to the fact that not all SQL syntax is implemented in ADQL (or some combination of both). I have tried various ways of going about it, such as the following query:
SELECT sss.ssObjectId, min(sss.diaSourceId) as diaSourceId, sss.heliocentricDist
FROM dp03_catalogs_10yr.SSSource AS sss
group by sss.ssObjectId, sss.heliocentricDist
however this returns all entries for each ssObjectId (not just the one with the minimum diaSourceId). Searching around, I found another possible approach here: https://stackoverflow.com/questions/15291506/sql-query-to-select-distinct-row-with-minimum-value and tried the query:
SELECT sss.*
FROM dp03_catalogs_10yr.SSSource AS sss
INNER JOIN
(
SELECT sss.ssObjectId, MIN(sss.diaSourceId) MinDiaSourceId
FROM sss
GROUP BY sss.ssObjectId
) tbl1
ON tbl1.id = sss.ssObjectId
WHERE tbl1.MinDiaSourceId = sss.diaSourceId
however, this results in the error: “sub-select not supported in FROM clause.”
I apologize if this is a very basic question or if it has been answered elsewhere on the forum, I have searched around through the entries and have not come across the same question, hopefully I did not miss something. Thank you so much for your time and for any suggestions you may have!