码迷,mamicode.com
首页 > 数据库 > 详细

新SQL temp

时间:2019-02-15 13:21:25      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:emc   mdi   time   price   code   rop   number   creat   nta   

select 
        a.createtime,                        -- 日期
        dept.name as deptName,                -- 科室
        (select t.docname from (
            SELECT u.clinic_id AS clinicid, u.id AS docid,u1.property_value AS docname
                FROM thc_warehouse.staff_record u
            LEFT JOIN thc_warehouse.staff_record_property u1 ON u1.property_code = SXX000083 AND u.id = u1.staff_record_id
        ) t where t.docid = a.orderDoctor ) AS doctor     -- 医生
        e.outpatient_number,                -- 门诊编号 档案号
        p.name,                             -- 客户名字
        p.age,                                -- 年龄
        p.country,                            -- 国籍/语言
        p.language,                            -- 语言
        b.itemClassName,                    -- 项目类型
        b.itemName,                            -- 项目名称
        -- b.fatherItemClassName,
        -- b.itemDisName,
        
        -- b.returnQuantity,                    -- 退货数量
        b.price,                             -- 原单价
        ROUND(b.discount * 100,0),            -- 折扣比
        round(b.price * b.quantity,4) as subPrice,   -- 折后价
        b.quantity,                             -- 购买数量
        b.amount,                            -- 折后总金额
        b.preFee,                            -- 原总价
        
        
from 
    `thc_rcm`.`Cs_AccountBill` a 
INNER JOIN `thc_rcm`.`Cs_AccountBillDetail` b on a.id =b.AccountBillId
INNER JOIN `thc_passport`.`patient` p on a.patientID = p.id
INNER JOIN `thc_sob`.`bpm_serv_provider` dept on a.clinicID = dept.id
LEFT  JOIN `thc_passport`.`patient_org` e on a.patientID = e.patient_id
LEFT  JOIN `thc_passport`.`contact` i on a.patientID = i.patient_id


where `quantity` > 0 and a.is_refund = 0 and b.returnQuantity < b.`quantity` -- and b.`returnQuantity` > 0;

select * from  thc_sob.bpm_serv_provider

 

新SQL temp

标签:emc   mdi   time   price   code   rop   number   creat   nta   

原文地址:https://www.cnblogs.com/guchunchao/p/10382861.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!