首页 技术 正文
技术 2022年11月6日
0 收藏 532 点赞 865 浏览 621 个字

1.Postgresql查询前几条记录的SQL语句

select * from table where …… LIMIT N  ;

2.SQL limit integer offset integer

:经常用到在数据库中查询中间几条数据的需求。

比如下面的sql语句:

① select * from testtable limit 2,1;

② select * from testtable limit 2 offset 1;

这两个都是能完成需要,但是他们之间是有区别的:

① 是从数据库中第三条开始查询,取一条数据,即第三条数据

② 是从数据库中的第二条数据开始查询两条数据,即第二条和第三条。

3.distinct icd01:查询表中icd01值去重后的数目

select distinct icd01, icd02 from drug_icd a inner join rcp_icd10 d on a.icd=d.icd01 where cag<>”;

4.split_part(text1,text2,integer):根据text2分割字符串text1,从interger(从1开始)位置开始取到text2位置(不包括text2字符)的字符串。

比如:取表ICD10中字段icd01第一个小数点前的字符

(查询结果)

SQL语句:select split_part(icd01,’.’,1) from icd10 ;

5.Coalesce(sum(value1),0):相当于SQL Server中的Isnull(num1,0),非空判断

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,982
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,499
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,343
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,126
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,760
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,796