博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL中间
阅读量:6176 次
发布时间:2019-06-21

本文共 2215 字,大约阅读时间需要 7 分钟。

 

-- 查询门诊挂号退费的账单:有4条记录

select * from `thc_rcm`.`Cs_AccountBill` a

where a.orderSource = 1 and a.orderType = 3 and a.returnFlag = 1

 

查询这4个退费订单:

 

select * from `thc_sob`.`bpm_service_order` b

where b.id in (
'ce33db6a-05f6-11e9-9ee0-0242ac110026',
'8077a88f-05fd-11e9-9ee0-0242ac110026',
'df40c79c-04fe-11e9-9ee0-0242ac110026',
'cf800ee7-05f7-11e9-9ee0-0242ac110026');

 

status 3个是-1,一个是0

 

 

-- 查询挂号单退费记录:只查到了2个

select *

from `thc_arrange`.`bpm_appointment` a
where appointment_date in ('2018-12-21','2018-12-22') and a.appointment_state = -1

 

查询条件:非退款

-----------------------------------------------

select * from `thc_arrange`.`bpm_appointment` a
inner join `thc_sob`.`bpm_service_order` b on a.orderId = b.id
inner join `thc_sob`.`bpm_service_order_item` c on c.service_order_id = b.id and c.id = a.order_item_id
inner join `thc_rcm`.`Cs_AccountBill` d on d.orderID = b.id and d.`isDelete` = 0 and d.orderSource = 1 and d.orderType = 3 and d.returnFlag = 0
inner join `thc_rcm`.`Cs_AccountBillDetail` e on d.id = e.AccountBillId and e.itemClass = 1 and e.returnFlag is NULL
inner join `thc_rcm`.`Cs_SettlementDetail` f on f.accountBillID = d.id and f.accountBillDetailID = e.id
inner join `thc_rcm`.`Cs_Settlement` g on g.id = f.settlementID and g.settlementType=2 and g.`isDelete` = 0 and g.returnFlag = 0 -- 门诊挂号

 

查询条件:退款

-----------------------------------------------

select * from `thc_arrange`.`bpm_appointment` a
inner join `thc_sob`.`bpm_service_order` b on a.orderId = b.id
inner join `thc_sob`.`bpm_service_order_item` c on c.service_order_id = b.id and c.id = a.order_item_id
inner join `thc_rcm`.`Cs_AccountBill` d on d.orderID = b.id and d.`isDelete` = 0 and d.orderSource = 1 and d.orderType = 3 and d.returnFlag = 1
inner join `thc_rcm`.`Cs_AccountBillDetail` e on d.id = e.AccountBillId and e.itemClass = 1 and e.returnFlag is not NULL
inner join `thc_rcm`.`Cs_SettlementDetail` f on f.accountBillID = d.id and f.accountBillDetailID = e.id
inner join `thc_rcm`.`Cs_Settlement` g on g.id = f.settlementID and g.settlementType=2 and g.`isDelete` = 0 and g.returnFlag = 1 -- 门诊挂号

 

 

 

 

 

 

 

按照医生统计的前2个是替换好的联查join SQL

---------------------------------------------------

 

转载于:https://www.cnblogs.com/guchunchao/p/10162990.html

你可能感兴趣的文章
Linux之文件压缩解压命令
查看>>
APP,Web Application(Web APP)等概念讲解
查看>>
Linux学习之CentOS(二)--初识linux的一些常用命令
查看>>
Java下一个简单的数据库分库帮助类
查看>>
lsyncd同步搭建
查看>>
交换机配置vlan 访问控制列表
查看>>
kickstart中ks.cfg指定目标机ip的小备忘
查看>>
MYSQL
查看>>
windows xp登录即注销的解决办法
查看>>
AngularJs-07-指令
查看>>
华为USG防火墙基本配置
查看>>
Exchange Server 2010 创建用户邮箱
查看>>
Win8 Metro(C#)数字图像处理--2.74图像凸包计算
查看>>
mysql--用脚本实现分库分表备份
查看>>
dig挖出DNS的秘密
查看>>
sphinx 增量索引 分布式索引 实例
查看>>
InnoDB Plugin1.0.7的新特性【快速恢复】
查看>>
***iOS 项目的目录结构能看出你的开发经验
查看>>
iptables中state模块的连接状态
查看>>
/usr/local/lib/libltdl.a(ltdl.o): could not read symbols: Bad value
查看>>