SQL查询笔记

SQL查询笔记
SELECT cust.id,cust.name,status.name,rate.name,cust.phone,region.name,area.location,(select max(contactdate) from hqoa.t_hq_app_crm_cust_contact where customerid=cust.id  ) as contactdate         FROM  hqoa.t_hq_app_crm_cust cust, hqoa.t_hq_app_crm_cust_type type, hqoa.t_hq_app_crm_cust_status status, hqoa.t_hq_app_crm_cust_rate rate, hqoa.t_hq_app_crm_cust_region region, hqoa.t_hq_app_crm_cust_area area              WHERE  type.id=cust.typeid and  status.id=cust.statusid and rate.id=cust.rateid and region.id=cust.regionid and cust.city=area.no order by contactdate desc , cust.id desc


select (select name from t_hq_app_crm_cust_source where id=sourceid),count(sourceid) from t_hq_app_crm_cust group by sourceid

你可能感兴趣的:(SQL查询笔记)