Oracle 同一个字段的两值进行加减计算
如
病人ID 入院日期 出院日期
00001 2016-09-01 2016-09-10
00001 2016-09-15 2016-09-30
计算病人00001 是否10天内再次入院
select b.patient_id, trunc(b.admission_date_time)-trunc(d.discharge_date_time) from
(select a.patient_id ,a.visit_id,a.admission_date_time,a.discharge_date_time from pat_visit a where a.admission_date_time<to_date('2016-09-30','yyyy-mm-dd')+1 and a.admission_date_time>=to_date('2016-07-01','yyyy-mm-dd')) b
left join
(select c.patient_id ,c.visit_id,c.admission_date_time,c.discharge_date_time from pat_visit c) d
on b.patient_id=d.patient_id and b.visit_id=d.visit_id+1
left join operation e on d.patient_id=e.patient_id and d.visit_id=e.visit_id
where trunc(b.admission_date_time)-trunc(d.discharge_date_time)<30 ;
Oracle 同一个字段的两值进行加减计算的更多相关文章
- 转 Oracle 同一个字段的两值进行加减计算
https://www.cnblogs.com/hjianguo/p/6041617.html 如 病人ID 入院日期 出院日期 00001 2016 ...
- MySQL 时间函数加减计算
一.MySQL 获得当前日期时间 函数 1.1 获得当前日期 + 时间(date + time) 函数:now() mysql> select now();+———————+| now() |+ ...
- freemarker 数据做加减计算
controller的部分: @Controller@RequestMapping("/ContactsFrameIndex")public class ContactsFrame ...
- python datetime库使用和时间加减计算
datetime库使用 一.操作当前时间 1.获取当前时间 >>> import datetime >>> print datetime.datetime.now( ...
- SQL Server--一个存储过程对同一个字段执行两种Update
需求: 服务器程序被界面点击"置零"按钮后,所有未完成的任务的状态都置为异常结束. 但分两种情况: 0<=Status<40状态为未完成的任务1,其异常结束状态为50 ...
- JS不用通过其他转换两个小数加减得到正确答案
之前写过一篇文章js比较两个属于float类型的小数,都需要通过某种函数转换下,太麻烦了,比如: 减法:10.2345-0.01=10.2245,这是正确的答案,但是当你做加法的时候就变了 加法:10 ...
- Excel:一列是源值随机加减某随机值,变为另一列的数值
1) 产生x1与x2之间整数随机数 =RANDBETWEEN(x1,x2),x1和x2为随机数区间 如果需要小数,可以乘以小数获得,Eg: =RANDBETWEEN(-5,5)*0.01,表示 -0. ...
- Java 日期加减计算.
1.用Java.util.Calender来实现 Calendar calendar=Calendar.getInstance(); calendar.setTime(new Date()) ...
- C# 两个时间相减 计算两个时间差(年月日时分秒)
DateTime dt1; DateTime dt2; int days=(dt2.Date-dt1.Date).Days; 或者 TimeSpan ts = dt2 -dt1; ...
随机推荐
- 逆向路由器固件之敏感信息泄露 Part2
之前的文章中详细介绍了各种解包路由器固件的工具.解包之后就获得了固件中的文件.下一步就是分析文件寻找漏洞了.这次分析的目标是Trendnet路由器,分析的漏洞是一个远程获取路由器权限的漏洞. 初步分析 ...
- scss学习笔记
1.引用父选择符: & #main { color: black; a { font-weight: bold; &:hover { color: red; } } } 2.font: ...
- react-> webstrom 配置
React Library支持
- [LeetCode&Python] Problem 682. Baseball Game
You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...
- CodeForces - 1098.DIV1.C: Construct a tree(贪心,构造)
Misha walked through the snowy forest and he was so fascinated by the trees to decide to draw his ow ...
- POJ 2441 Arrange the Bulls 状态压缩递推简单题 (状态压缩DP)
推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文 ...
- Ubuntu 18.10 安装PDF阅读器
======================================== 软件开发转移到了 Linux上,使用Ubuntu 18.10作为桌面开发环境 下面介绍 安装PDF阅读器 1.下载 福 ...
- SQL Server常用SQL集合
================================================ 1.SQL查询一年之内的数据记录 select * from 表名 where CreateDate& ...
- 结构体内的函数与bfs的情景变量
关于结构体内的函数,太难的尚且不会用,下面是一个简单一点的结构体内函数的代码 定义这样一个结构体函数之后就能像如下这样使用了 以上为结构体内的简单函数,下面重点来了,关于bfs找最短路由于需要避免走回 ...
- 【问题】解决在微信公众号里面网站无法访问:oops something went wrong:(
最近在用一个第三方微信公众平台托管工具连接微信公众平台时,发现一个问题——在微信里面的官网网站链接没法在微信里面打开(无论是手机端还是PC端),会出现Oops! Something went wron ...