SELECT areasymbol AS Area_symbol, areaname AS Area_name, mu.mukey AS MUKEY, musym AS Map_unit_symbol,
muname AS Map_unit_name, CASE WHEN localphase IS NULL THEN compname ELSE compname + ', ' + localphase END AS Component_name_and_phase,
comppct_r AS Component_percentage, (mu.muacres*co.comppct_r/100) AS Component_acres,
(SELECT TOP 1 cogeomordesc.geomfname FROM cogeomordesc
WHERE co.cokey = cogeomordesc.cokey AND cogeomordesc.rvindicator='yes' AND cogeomordesc.geomftname = 'Landform') AS Landform,
SUBSTRING( ( SELECT ( ', ' + hydriccriterion)
FROM component AS co1
INNER JOIN cohydriccriteria AS coh1 ON coh1.cokey=co1.cokey
AND co.cokey = co1.cokey ORDER BY hydriccriterion, co1.cokey, co.cokey, cohydcritkey
FOR XML PATH('') ), 3, 50) as Hydric_criteria
FROM legend AS l
INNER JOIN mapunit AS mu ON l.lkey = mu.lkey AND LEFT (l.areasymbol, 2) LIKE
'TX'
INNER JOIN component AS co ON mu.mukey = co.mukey AND hydricrating = 'yes'
ORDER BY areasymbol, musym