SELECT
sc.areasymbol AS AREA_SYMBOL,
m.mukey AS MUKEY,
m.musym AS Map_unit_SYM,
m.muname AS Mapunit_name,
compname AS Component_name,comppct_r as Component_percent,
(SELECT TOP 1 MIN (soimoistdept_r)
FROM component AS c_sl
INNER JOIN comonth ON comonth.cokey=c_sl.cokey AND c_sl.cokey=c.cokey
INNER JOIN cosoilmoist ON cosoilmoist.comonthkey=comonth.comonthkey
AND soimoiststat = 'Wet'
GROUP BY c_sl.cokey, soimoistdept_r) AS Water_table_depth_wet
FROM sacatalog AS sc
INNER JOIN legend AS l ON l.areasymbol = sc.areasymbol AND sc.areasymbol LIKE
'WI007'
INNER JOIN mapunit AS m ON m.lkey = l.lkey
INNER JOIN component AS c ON c.mukey = m.mukey AND c.cokey =
(SELECT TOP 1 c1.cokey
FROM component AS c1
INNER JOIN mapunit AS mu1 ON c1.mukey=mu1.mukey AND c1.mukey=m.mukey
ORDER BY c1.comppct_r DESC, c1.cokey)