全連接 左連接 區別?
單輸入框多條件查詢 子查詢
(查詢添加關注的聯繫人)
傳入參數 :keyword :userId
--------------------
--getFollowContactByNameselect *,get_first_pinyin_char(contact_name) as py from crm_contact g
left join crm_customer s on g.customer_id = s.customer_id
where g.deleteflag <> 'Y'
and (exists (select 1 from crm_contact_follow fc where fc.contact_id = g.contact_id and fc.system_user_id = :userId))
<#if keyword?? && keyword != "">
and (g.contact_name like :keyword
or g.contact_sex like :keyword
or g.contact_email like :keyword
or g.contact_mobile like :keyword
or g.contact_qq like :keyword
or g.contact_duties like :keyword
or g.contact_address like :keyword)
</#if>
order by py
子查詢:exsit(返回:true/false) in 區別
統計功能
--------------------
--getClueStatistics
select count(clue.clue_id) AS cluecount,
count(oppo.business_opportunity_id) AS oppocount,
count(contract.contract_id) AS contractcount,
sum(clue.clue_possibility)/count(clue.clue_id) AS possibility,
customer.costomer_rank AS cusrank,
sum(oppo.real_pre_cost) AS realcost
from crm_clue clue
left join crm_business_opportunity oppo
on clue.clue_processID = oppo.process_id
left join crm_contract contract
on clue.clue_processID = contract.process_id
left join crm_process process
on clue.clue_processID = process.process_id
left join crm_customer customer
on clue.clue_customer_name = customer.customer_name
where clue.clue_customer_name = (select clue_customer_name from crm_clue where clue_id = :clueId) and clue.clue_id <> :clueId
連接字符串
concat("中國 ",clue.clue_customer_province," ", clue.clue_customer_city," ",clue.clue_customer_county)