DB(SQL)/기타
[PostgreSQL] How to select the first observation in a category in PostgreSQL
24시간초보
2022. 12. 13. 16:33
반응형
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
반응형