求助啊,关于sql的内联子查询
以下的的sql语句是不是内联子查询???内联子查询都在什么情况下使用???
select
tt.*
from
(
SELECT
t.*,
t1.is_complete isComplete,
t1.is_original isOriginal,
t1.is_sale isSale,
t1.score score,
t2.shop_logo shopLogo,
t2.shop_name shopName,
(SELECT if((IFNULL(SUM(co.attitude),0) + IFNULL(SUM(co.quality),0) +IFNULL(SUM(co.speed),0))/3/if(COUNT(1)=0,1,COUNT(1))=0,0,(SUM(co.attitude) + SUM(co.quality) +SUM(co.speed))/3/if(COUNT(1)=0,1,COUNT(1))) FROM t_servicer_comment co WHERE co.servicer_id = t.id) avg,
(
select
CONCAT(",",GROUP_CONCAT(t3.product_type_id SEPARATOR ',') ,",")
from t_servicer_product_type t3
where t3.servicer_id = t.id
) as productTypeIds,
(
select
GROUP_CONCAT(t4.name SEPARATOR ',')
from t_servicer_product_type t3
LEFT JOIN t_product_type t4 ON t4.id = t3.product_type_id
where t3.servicer_id = t.id
) as productTypeNames,
(
SELECT IFNULL(SUM(tr.money),0) FROM t_trade_record tr WHERE tr.employer_id = t.employer_id AND tr.trade_type = 1 AND tr.status IN (3,4)
) tradeTotal,
(
SELECT IFNULL(COUNT(1),0) FROM t_trade_record tr WHERE tr.employer_id = t.employer_id AND tr.trade_type = 1 AND tr.status = 4
) tradeNum,
(
SELECT (IFNULL((SUM(co.attitude) + SUM(co.quality) +SUM(co.speed))/3/COUNT(1),0)+IFNULL(level_score,0)+IFNULL(score,0))/3 FROM t_servicer_comment co WHERE co.servicer_id = t.id
) compre
FROM
t_servicer t
LEFT JOIN t_servicer_credit t1 ON t1.servicer_id = t.id
LEFT JOIN t_servicer_shop t2 ON t2.servicer_id = t.id
) tt
where 1 = 1 AND tt.status = #{status} AND tt.audit_status =2
<if test="typeId != null and typeId != ''">
AND tt.productTypeIds like CONCAT('%,',#{typeId},',%')
</if>
<if test="shopName != null and shopName != ''">
AND tt.shopName like CONCAT('%',#{shopName},'%')
</if>
<if test="code != '' and code != null">
and tt.level_score BETWEEN #{mixScore} AND #{maxScore}
</if>
<if test="isComplete != null and isComplete !=''">
and tt.isComplete = 1
</if>
<if test="isOriginal != null and isOriginal !=''">
and tt.isOriginal = 1
</if>
<if test="isSale != null and isSale !=''">
and tt.isSale = 1
</if>
<if test="province != null and province != ''">
AND tt.province = #{province}
</if>
<if test="commitment == 1 or commitment == '1' ">
and tt.isComplete = 1
</if>
<if test="commitment == 2 or commitment == '2' ">
and tt.isOriginal = 1
</if>
<if test="commitment == 3 or commitment == '3' ">
and tt.isSale = 1
</if>
<!-- 排序方法(1信用 2能力等级 3交易金额 4中标次数 6好评率 7综合)-->
<if test="(order == '1' or order == 1) and(sort == 1 or sort == '1')">
ORDER BY tt.score desc
</if>
<if test="(order == '1' or order == 1) and(sort == 2 or sort == '2')">
ORDER BY tt.score asc
</if>
<if test="(order == '2' or order == 2) and(sort == 1 or sort == '1')">
ORDER BY tt.level_score desc
</if>
<if test="(order == '2' or order == 2) and(sort == 2 or sort == '2')">
ORDER BY tt.level_score asc
</if>
<if test="(order == '3' or order == 3) and(sort == 1 or sort == '1')">
ORDER BY tt.tradeTotal desc
</if>
<if test="(order == '3' or order == 3) and(sort == 2 or sort == '2')">
ORDER BY tt.tradeTotal asc
</if>
<if test="(order == '4' or order == 4) and(sort == 1 or sort == '1')">
ORDER BY tt.tradeNum desc
</if>
<if test="(order == '4' or order == 4) and(sort == 2 or sort == '2')">
ORDER BY tt.tradeNum asc
</if>
<if test="(order == '6' or order == 6) and (sort == 1 or sort == '1')">
ORDER BY tt.avg desc
</if>
<if test="(order == '6' or order == 6) and (sort == 2 or sort == '2')">
ORDER BY tt.avg asc
</if>
<if test="(order == '7' or order == 7) and(sort == 1 or sort == '1')">
ORDER BY tt.compre DESC
</if>
<if test="(order == '7' or order == 7) and(sort == 2 or sort == '2')">
ORDER BY tt.compre asc
</if>
LIMIT ${pageStart},${pageSize}