首页 > 开发 > 综合 > 正文

不错的sql

2024-07-21 02:51:58
字体:
来源:转载
供稿:网友
关联多张表查询但查询结果只要求一条的情况下,可以使用as后面拼接数据,虽然简单,但是大多数情况下,我们都会惯性思维使用left join或其他,但是如果需要一条查询结果,那么这种方式是一种不错的解决方案 select a.ID as id , a.member_no as memberNo , a.member_name as memberName , a.company_id_ex as companyIdEx , a.DOCUMENT_TYPE as documentType , a.member_idcredno as memberIdCredNo , a.csource_name as csourceName , a.csource_sys as csourceSys , a.TELEPHONE as telephone , a.ADDRESS as address , a.LEVEL_ID as levelId , a.LEVEL_NAME as levelName , a.CREDIT_LIMIT as creditLimit , a.USABLE_LIMIT as usableLimit , a.GUARANTEE as guarantee , a.start_date_q as startDateQ , a.end_date_t as endDateT , a.bt_member_status as btMemberStatus , a.modify_id as modifyId , a.GMT_CREATE as gmtCreate , a.GMT_MODIFY as gmtModify , a.USED_LIMIT as usedLimit , (select nvl(sum(c.repay_amount),0) from fc_bt_bill b,fc_bt_bill_detail c where b.id=c.bill_id and c.bill_d_status=1 and b.member_id=a.id) as norepayment , (select nvl(sum(c.repay_amount),0) from fc_bt_bill b,fc_bt_bill_detail c where b.id=c.bill_id and c.bill_d_status=2 and b.member_id=a.id) as repayment ,(SELECT nvl(sum(b.finance_blance),0) from fc_bt_bill b where b.member_id = a.id) as refund from FC_BT_MEMBER a where a.company_id_ex=#companyId#
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表