新SQL temp
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
select
a.createtime, -- 日期
( select name from `thc_passport`.`city` where id =
(
select JSON_UNQUOTE(JSON_EXTRACT(property_value,'$.city'))
from `thc_warehouse`.`clinic_property`
where property_code = 'SXX000059'
and property_value is not null
and JSON_UNQUOTE(JSON_EXTRACT(property_value,'$.city')) is not null
and clinic_id = a.clinicID
)
) as zenSuoCity, -- 城市
(select property_value from `thc_warehouse`.`clinic_property` where property_code = 'SXX000055' and clinic_id = a.clinicID) as zenSuo, -- 诊所
(select property_value from `thc_warehouse`.`clinic_property` where property_code = 'SXX000063' and clinic_id = a.clinicID) as zenSuoCode, -- 诊所代码
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.patient_number, -- 档案号
p.name, -- 客户名字
p.age, -- 年龄
p.country as countryBak,
p.language as languageBak,
(
select bb.name
from `thc_warehouse`.`sys_type` aa
join `thc_warehouse`.`sys_type_info` bb on aa.id = bb.sys_type_id
where aa.code = 'THC_RCM_COUNTRY' and bb.id = p.country
) as country, -- 国籍
(
select bb.name
from `thc_warehouse`.`sys_type` aa
join `thc_warehouse`.`sys_type_info` bb on aa.id = bb.sys_type_id
where aa.code = 'PASSPORT_LANGUAGE' and bb.id = p.language
) as language, -- 语言 b.itemClassName, -- 项目类型
b.itemName, -- 项目名称
b.price, -- 原价
ROUND(b.discount * 100,0), -- 折扣比
round(b.price * b.quantity,4) as subPrice, -- 折后价
ROUND(b.quantity,0), -- 数量
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
INNER JOIN `thc_passport`.`patient_org` e on a.patientID = e.patient_id where a.is_refund = 0 and `quantity` > 0 and b.returnQuantity < b.`quantity` -- and b.`returnQuantity` > 0; limit 10; select b.
from `thc_warehouse`.`clinic` a
join `thc_warehouse`.`clinic_property` b on a.id = b.clinic_id
where a.id in (1,2002)
order by b.clinic_id,b.property_code -- join `thc_warehouse`.`clinic_property_value` c select b.code,b.name,b.value,b.id
from `thc_warehouse`.`sys_type` a
join `thc_warehouse`.`sys_type_info` b on a.id = b.sys_type_id
where a.code = 'THC_RCM_COUNTRY'
order by value select * from `thc_warehouse`.`sys_type_info` where code like 'htc_00000009%'; select id,name from `thc_passport`.`city` where id like '___0000000' select * from `thc_passport`.`city` where id not like '___0000000' and id = REGEXP '1010[1-9]{1}[0-9]?'
SQL2:消费项目汇总统计
select
( select name from `thc_passport`.`city` where id =
(
select JSON_UNQUOTE(JSON_EXTRACT(property_value,'$.city'))
from `thc_warehouse`.`clinic_property`
where property_code = 'SXX000059'
and property_value is not null
and JSON_UNQUOTE(JSON_EXTRACT(property_value,'$.city')) is not null
and clinic_id = a.clinicID
)
) as zenSuoCity, -- 城市
(select property_value from `thc_warehouse`.`clinic_property` where property_code = 'SXX000055' and clinic_id = a.clinicID) as zenSuo, -- 诊所
(select property_value from `thc_warehouse`.`clinic_property` where property_code = 'SXX000063' and clinic_id = a.clinicID) as zenSuoCode, -- 诊所代码
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, -- 医生
b.itemClassName, -- 项目类型
b.itemName, -- 项目名称
ROUND(sum(b.quantity),0) AS quantity, -- 总数量
sum(b.preFee) as sumFee, -- 原价总价
sum(b.amount) as subSumFee -- 折后总金额
from
`thc_rcm`.`Cs_AccountBill` a
INNER JOIN `thc_rcm`.`Cs_AccountBillDetail` b on a.id =b.AccountBillId
INNER JOIN `thc_sob`.`bpm_serv_provider` dept on a.clinicID = dept.id
where
a.is_refund = 0 -- 是买非退
and b.quantity > 0 -- 数量大于0
and b.returnQuantity < b.quantity -- 未退完的
group by b.itemClassName,b.itemName
-- limit 10
SQL3 monthly sale report(统计人次)
select
b.* from
`thc_rcm`.`Cs_AccountBill` a
INNER JOIN `thc_rcm`.`Cs_AccountBillDetail` b on a.id =b.AccountBillId
INNER JOIN `thc_rcm`.`Cs_SettlementDetail` d on d.accountBillDetailID = b.id and d.accountBillID = a.id
INNER JOIN `thc_rcm`.`Cs_Settlement` c on c.id = d.settlementID
INNER JOIN `thc_passport`.`patient` p on a.patientID = p.id
INNER JOIN `thc_sob`.`bpm_serv_provider` dept on a.orderDept = dept.id
INNER JOIN `thc_passport`.`patient_org` e on a.patientID = e.patient_id where
a.is_refund = 0 -- 是买非退
and b.quantity > 0 -- 数量大于0
and b.returnQuantity < b.quantity -- 未退完的
limit 10 ${if(len(startTime) == 0,"","AND a.createtime >= '" + startTime + "'")} -- 开始时间
${if(len(endTime) == 0,"","AND a.createtime <= '" + endTime + "'")} -- 结束时间
${if(len(zenSuo) == 0,"","AND a.clinicID = '" + zenSuo + "'")} -- 诊所
${if(len(zenSuoCode) == 0,"","AND a.clinicID = '" + zenSuoCode + "'")} -- 诊所代码
${if(len(deptId) == 0,"","AND a.orderDept = '" + deptId + "'")} -- 科室
${if(len(doctor) == 0,"","AND a.orderDoctor = '" + doctor + "'")} -- 医生
${if(len(patientNum) == 0,"","AND e.patient_number like '%" + patientNum + "%'")} -- 客户档案号
${if(len(itemClassName) == 0,"","AND b.itemClassName like '%" + itemClassName + "%'")} -- 项目类型
${if(len(itemName) == 0,""," AND (b.itemName like '%" + itemName + "%' or b.itemCode like '%"+ itemName + "%')")} -- 项目
) t
where 1=1
${if(len(city) == 0,"","AND t.zenSuoCity = '" + city + "'")} -- 城市
order by t.createtime desc
新SQL temp的更多相关文章
- Oracle 11g新特性
文章转自网络 Oracle 11g于2007年7月11日美国东部时间11时(北京时间11日22时)正式发布,11g是甲骨文公司30年来发布的最重要的数据库版本,根据用户的需求实现了信息生命周期管理(I ...
- 11g新特性-概述 (转)
一.新特性提纲 1.数据库管理部分 ◆数据库重演(Database Replay) 这一特性可以捕捉整个数据的负载,并且传递到一个从备份或者standby数据库中创建的测试数据库上,然后重演负责以测试 ...
- Oralce 11g新特性 转载
Oracle 11g于2007年7月11日美国东部时间11时(北京时间11日22时)正式发布,11g是甲骨文公司30年来发布的最重要的数据库版本,根据用户的需求实现了信息生命周期管理(Informat ...
- SQL Server中的事务日志管理(7/9):处理日志过度增长
当一切正常时,没有必要特别留意什么是事务日志,它是如何工作的.你只要确保每个数据库都有正确的备份.当出现问题时,事务日志的理解对于采取修正操作是重要的,尤其在需要紧急恢复数据库到指定点时.这系列文章会 ...
- 使用第三方分页AspNetPager实现真正分页的SQL原理
AspNetPager是一个第三方分页第三方控件,可以和数据绑定控件(GridView等)方便的结合,实现真分页. 真分页:从数据库中获取符合要求的部分数目的记录.性能较高,数据量小,网络负载小,对数 ...
- SQL Server数据库中还原孤立用户的方法集合
虽然SQL Server现在搬迁的技术越来越多,自带的方法也越来越高级. 但是我们的SQL Server在搬迁的会出现很多孤立用户,微软没有自动的处理. 因为我们的数据库权限表都不会在应用数据库中,但 ...
- 针对大的sql文件删除行操作
今天处理开发已导出的库的一个sql文件.未gzip压缩 ,1.3G 需要删除 17 18 24行的SET行. 想到了两个办法 1 sed 方法 主意 由于 sed 虽然指定行 进行 替换, 也会读完 ...
- PL/SQL常用设置 可看引用位置更清晰直观 引自:http://blog.csdn.net/xiaoqforever/article/details/27695569
引自:http://blog.csdn.net/xiaoqforever/article/details/27695569 1,登录后默认自动选中My Objects 默认情况下,PLSQL Deve ...
- 微软ASP.NET网站部署指南(10):迁移至SQL Server
1. 综述 第2章的部署SQL Server Compact和第9章的部署数据库更新里解释了为什么终于要升级到完整版SQL Server .本章节将告诉你怎样来做. SQL Server Expre ...
随机推荐
- linux rpm安装 failed depenencie(失败的依赖关系)错误原因
rpm安装nfs 出现failed depenencie 经查资料得知命令后加上--nodeps --force,就可以了 加上那两个参数的意义就在于,安装时不再分析包之间的依赖关系而直接安装,也就不 ...
- 小电阻之大作用——CAN终端电阻
CAN总线终端电阻,顾名思义就是加在总线末端的电阻.此电阻虽小,但在CAN总线通信中却有十分重要的作用. 终端电阻的作用 CAN总线终端电阻的作用有两个: 1.提高抗干扰能力,确保总线快速进入隐性状态 ...
- VSCode创建自定义代码段
上一篇:PyCharm创建自定义代码段(JetBrains系列通用) 设置方法 很简单,快速过一下,F1,然后输入snippets 然后选择对应语言 Python案例 内容和使用: { // pref ...
- POJ--3614 Sunscreen(贪心)
题目 3614 Sunscreen 2500*2500直接排序暴力贪心 #include<iostream> #include<cstring> #include<alg ...
- linux复制文件到一个不存在的文件夹
复制文件到一个不存在的文件夹时,会报错 cp -f aaa /home/admin/.m2/cp: 无法创建普通文件"/home/admin/.m2/": 是一个目录 解决的方式: ...
- poj2083 Fractal
我一开始的想法是间断性的输出空格和solve(k-1) 但是发现问题很大. 雨菲:可以用一个数组保存啊 我:那不爆了? 雨菲:不会爆. 我一算:729 × 729,还真没爆. 然后就直接WA了.... ...
- 【【洛谷P2678 跳石头】——%%%ShawnZhou大佬】
{dalao传送门} 这道题如果要使用暴力搜索直接求解会严重超时.实际上,我们可以发现,这个所谓的最短跳跃距离显然不能超过一个范围,而这个范围题目上已经给了出来.也就是说,答案是有一个确定的范围限制的 ...
- 跟我一起用node-express搭建一个小项目(mongodb)[二]
我的小项目主要是会用到MongoDB. 呵呵,我也是现学现卖. 都说小公司十八般武艺样样稀疏,没有办法啊! 兵来兵挡,将来将挡!自己是个兵呢?还是一个将呢! 没有公司培养,就自己培养自己呗.差的远一点 ...
- 第五篇 - Selenium突破反爬获取qq邮件标题
from selenium import webdriver from selenium.webdriver import ActionChains #1.打开登陆页面 wd = webdriver. ...
- python操作excel文件一(xlrd读取文件)
一般做接口测试,会把参数和一些数据放入excel表中,这样就不会重新编译代码,提高效率.一般如何操作呢?接下来跟着步骤一起学习吧 执行步骤: 1.首先要安装 xlrd这个模块,用 pip instal ...