postsql常用sql语句

1、从表中查询某一区间的记录

SELECT id from house LIMIT 100 OFFSET 20

100是要查询的条数,20为从开始的偏移量

2、从表中查询以某个字符开头的记录

SELECT * from house WHERE name LIKE '北%'

3、 删除重复数据

3.1、统计重复数据条数
select distinct houseid , count(*) from hous group by houseid having count(*) > 1
3.2、 删除重复数据
delete from house where ctid not in (select min(ctid) from house group by houseid)

4 生成时间序列

SELECT * FROM generate_series('2008-03-01 00:00'::date, '2008-03-04 12:00', '1 days')

参考:
https://blog.csdn.net/zhangzeyuaaa/article/details/50675058

你可能感兴趣的:(postsql常用sql语句)