select t.trade_day as businessDate, t.blemind2 as securityName,d.security_code as securityCode,d.number_ingredients as numberIngredients, d.opening_price as openingPrice,
d.closing_price as closingPrice,d.volume as volume,d.turnover as turnover,d.total_capitalization as totalCapitalization,d.free_capitalization as freeCapitalization,
d.change_percentage as changePercentage,d.highest_price as highestPrice,d.lowest_price as lowestPrice, d.rise_number as riseNumber,d.losses_number as lossesNumber,
d.flat_number as flatNumber, d.rise_stop_number as riseStopNumber,d.losses_stop_number as lossesStopNumber,d.stop_number as stopNumber,d.recently_high as recentlyHigh,
d.recently_low as recentlyLow,d.pe_ttm as peTtm,d.pe_center_ttm as peCenterTtm,t.sort as sort,t.sort_change as sortChange, t.trend_value as trendValue,t.trend_value_change as trendValueChange
from trends t
left join dong_cai_secondary_industry d on (t.blemind2 = d.security_name)
where t.trade_day = #{firstDate} and d.business_date = #{firstDate} and t.type = #{type}
<choose>
<whentest="sortSort != null and sortSort.trim() != '' and sortChangeSort != null and sortChangeSort.trim() != ''">
order by sort ${sortSort},sortChange ${sortChangeSort}
</when>
<otherwise>
<iftest="sortSort != null and sortSort.trim() != '' ">
order by sort ${sortSort}
</if>
<iftest="sortChangeSort != null and sortChangeSort.trim() != ''">