select rownum,t.cr_customer_number,t.cr_name,t.cr_idnum,(select f.tl_tel_num from crm_tel f where t.id=f.customerid and rownum=1),t.cr_gather_date from crm_customer t
order by t.cr_customer_number desc
select count((select f.tl_tel_num from crm_tel f where t.id=f.customerid and rownum=1)) as tel
from crm_customer t order by rownum desc
查询两条数据相同 选一条用 rownum
一下两条数据查询结果不同:
select t.cr_customer_number,t.cr_name,t.cr_idnum,f.tl_tel_num,t.cr_gather_date from crm_customer t
left join crm_tel f on t.id=f.customerid
order by t.cr_customer_number desc
select rownum,t.cr_customer_number,t.cr_name,t.cr_idnum,(select f.tl_tel_num from crm_tel f where t.id=f.customerid and rownum=1),t.cr_gather_date from crm_customer t order by t.cr_customer_number desc