반응형
select distinct on(dataid, date_trunc('day', readtime)) *
from university.gas_ert
where readtime between '2014-01-01' and '2014-01-02'
order by dataid, date_trunc('day', readtime) asc
How to select the first observation in a category in PostgreSQL
My table contains different house IDs(dataid), time of observation(readtime), meter reading Basic Output And the query is as follows Query statement : select * from university.gas_ert where readt...
stackoverflow.com
https://www.postgresdba.com/bbs/board.php?bo_table=B10&wr_id=47
지식창고 > SQL > DISTINCT ON (PostgreSQL 만의 고유 문법) - All About PostgreSQL
scott@[local]:5432:scottdb] SQL> create table test(x varchar(20), y int); scott@[local]:5432:scottdb] SQL> insert into test values('lion',2); INSERT 0 1 scott@[local]:5432:scottdb] SQL> insert into test values('lion',1); INSERT 0 1 scott@[local]:5432
www.postgresdba.com
반응형
'DB(SQL) > 기타' 카테고리의 다른 글
[Redis] 라이선스 변경 (0) | 2024.04.03 |
---|---|
[DB] PMM 구성하기 (DB Monitoring Tool) (0) | 2023.12.28 |
[DB] ERD TOOL (0) | 2021.12.08 |
Free ERD create Web site and Program (0) | 2021.09.23 |
[DB] 문서로하는 데이터베이스 변경 관리 liquibase (0) | 2021.08.30 |