Search Postgresql Archives

Re: Select latest Timestamp values with group by

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/10/11 12:55, Adarsh Sharma wrote:
Thanks Craig, but I solved the issue by the below query :-

Here is the query for that :-

select bb_id,lat,lon,speed,dt_stamp from demo_table
inner join
  (select bb_id as did, max(dt_stamp) as ts
  from demo_table group by bb_id) as ds
  on demo_table1.bb_id = ds.did and demo_table1.dt_stamp = ds.ts;

Yep, so you used the self-join method. That works, though it's probably quite a lot slower than using a window function for the job.

I'm glad you found a suitable solution for your needs.

--
Craig Ringer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux