自学数据库之一个自己写的SQL语句
来源:互联网 发布:c4d r17 mac破解 编辑:程序博客网 时间:2024/05/18 09:16
1,自己写的查询语句:
select b.yq,b.ybh,
a.ksdh,
a.sjys,
a.brdh as 住院号,
b.num_result as 检验结果,
b.jyrq as 检验日期,
a.brxm as 病人姓名,
(case a.brxb when '1' then '男' when '2' then '女' when 'F' then '女' when 'M' then '男' else '其他' end ) as 病人性别,
a.nl as 年龄,
(case a.nldw when '1' then '岁' when '2' then '月' when '3' then '天' when '4' then '时' else '其他' end ) as 年龄单位,
a.zd as 临床诊断,
(select zdmc from com_dict c where a.ksdh=c.zddh and zdlb='DP') as '科室/病区',
(select zdmc from com_dict c where a.sjys=c.zddh) as 申请医生
from lis_result b ,lis_pat a
where b.yq = a.yq and b.ybh=a.ybh and b.jyrq=a.jyrq
and b.jyrq>='2015-04-01' and b.jyrq<='2015-06-14' and b.xmdh='PLT' and b.num_result <75 order by b.jyrq
2,分析:
case。。。when.....then......when......then......else.........end
(select zdmc from com_dict c where a.ksdh=c.zddh and zdlb='DP') as '科室/病区', z注:加zdlb='DP'是为了解决返回多个值的问题
(select zdmc from com_dict c where a.sjys=c.zddh) as 申请医生
- 自学数据库之一个自己写的SQL语句
- 自己写的sql语句
- 自学数据库自己练习的
- magento -- 在Magento中使用自己写的SQL语句
- 记录自己常写的一些sql语句
- 记录自己常写的一些sql语句
- 数据库中写sql语句
- 写个自己的
- 写个自己的
- 自己写的个C#(ASP.NET)连接SQL数据库执行查询和修改操作的类
- 自己写的sql
- 今天写错的3个SQL语句
- 5、如何自己写SQL语句
- 经典的SQL语句 之一
- jsp写调用数据库的sql语句用了prepareStatement
- 怎样写SQL语句可以提高数据库的性能
- 怎样写SQL语句可以提高数据库的性能
- 怎样写SQL语句可以提高数据库的性能
- javascript数组基础知识(一)
- block和函数指针有什么区别
- 2015061702 - mysql从一个表中的数据插入到另一张表中
- STL源码剖析(1):空间配置器
- opencv中画图像的直方图
- 自学数据库之一个自己写的SQL语句
- OpenCV4Android 提取特征点描述符(Feature Descriptor)
- android Intent打开各种类型文件((PDF、word、excel、ppt、chm)
- LeetCode---(100)Same Tree
- 使用android模拟事件,python完成自动化测试
- ckeditor上传图片的实现
- bzoj-1305 dance跳舞
- MD5加密
- Lovo 6月17号课程总结