SELECT top 100 sl.specObjId,
sl.lineID,
sMax.maxVel
-- get the spectroscopic object ID, the line ID, and the max width (in velocity)
FROM SpecLine sl,
(SELECT specObjID,
lineID,
Max(2.99e5 * 2.354 * sigma / wave) as maxVel
FROM SpecLine
WHERE (
-- only include measured lines
category = 2
AND
-- only include the most prominent lines
lineID in ( 1215, 1400, 1549, 1909,
2799, 4863, 6565 )
AND
-- make sure that this is a reaonably well measured line
-- (these are fairly weak constraints)
nSigma > 3
AND chisq / nu < 20
AND ew > 0
AND abs(ew - height * sigma * 1.065 * 2.354 / continuum) / ew < 0.25 )
GROUP BY specObjID,
lineID) as sMax
SQL before beautify
SELECT top 100 sl.specObjId, sl.lineID, sMax.maxVel -- get the spectroscopic object ID, the line ID, and the max width (in velocity) FROM SpecLine sl, (SELECT specObjID, lineID, Max(2.99e5*2.354*sigma/wave) as maxVel FROM SpecLine WHERE ( -- only include measured lines category = 2 AND -- only include the most prominent lines lineID in (1215,1400,1549,1909,2799,4863,6565) AND -- make sure that this is a reaonably well measured line -- (these are fairly weak constraints) nSigma > 3 AND chisq/nu < 20 AND ew > 0 AND abs(ew - height*sigma*1.065*2.354/continuum)/ew < 0.25 ) GROUP BY specObjID, lineID) as sMax