Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu0of-0004up-Of for pgsql-sql@arkaria.postgresql.org; Thu, 08 Mar 2018 19:03:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eu0oe-0003Ac-GY for pgsql-sql@arkaria.postgresql.org; Thu, 08 Mar 2018 19:03:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu0oe-0003AT-7j for pgsql-sql@lists.postgresql.org; Thu, 08 Mar 2018 19:03:00 +0000 Received: from mail.inqbus.de ([164.177.165.236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eu0oa-0006Cf-IT for pgsql-sql@lists.postgresql.org; Thu, 08 Mar 2018 19:02:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stb-datenservice.de; s=20160215; h=Content-Type:In-Reply-To:MIME-Version: Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XgLjsdWoXvXrtorMkGq82nwx84yhHk6gtkybSdCQxmc=; b=Fsa/OEqmMYDnQLDCGJdpa/PZl vWcR/6fpdUCHyd/VE+YGslJGG6a18ExhtJiRynequEISOGS1BMqoS89D0ELrQquTvXJkjZ5Z1Qqjh ACObbYpWqo/vwUXQzSU/JPAu7n9Ow+yal6JWoLSF0Nm2/LBbD5OElLJkjLXAwbVdUAVY8=; Received: from x4db4162b.dyn.telefonica.de ([77.180.22.43]:62114 helo=[192.168.178.20]) by mail.inqbus.de with esmtpa (Exim 4.89) (envelope-from ) id 1eu0oY-0001SC-7y for pgsql-sql@lists.postgresql.org; Thu, 08 Mar 2018 20:02:54 +0100 Subject: Re: Query question To: pgsql-sql@lists.postgresql.org References: <415803152.48510563.1520535505737.JavaMail.zimbra@rglholdings.com> From: =?UTF-8?Q?Martin_St=c3=b6cker?= Message-ID: Date: Thu, 8 Mar 2018 20:07:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <415803152.48510563.1520535505737.JavaMail.zimbra@rglholdings.com> Content-Type: multipart/alternative; boundary="------------38FB428AF38474977D3563C2" Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------38FB428AF38474977D3563C2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit My first idea is to select all equipments and lateral join them to the 5 most recent events Regards Martin Am 08.03.2018 um 19:58 schrieb Stanton Schmidt: > Hi, > I am new to the list so feel free to let me know if I am out of line. > > My question is: > I have a table that has log events for pieces of equipment.  For each > piece of equipment this table may contain 1 or more (hundreds > potentially). > I need to write a query that will return only the last 5 log events > for each (and every) piece of equipment. > > log_table ( > equipment_id character(30), > log_date date, > log_time time, > event_desc text > ) > > Thanks for your help. > > *stanton schmidt* > *Database Administrator* > direct. 920. 471.4495  cell 920.660.1828 > > RGL > GO AHEAD.ASKWHAT IF. > www.RGLlogistics.co m --------------38FB428AF38474977D3563C2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit My first idea is to select all equipments and lateral join them to the 5 most recent events

Regards Martin

Am 08.03.2018 um 19:58 schrieb Stanton Schmidt:
Hi, 
I am new to the list so feel free to let me know if I am out of line.

My question is:
I have a table that has log events for pieces of equipment.  For each piece of equipment this table may contain 1 or more (hundreds potentially).
I need to write a query that will return only the last 5 log events for each (and every) piece of equipment.

log_table (
equipment_id character(30),
log_date date,
log_time time,
event_desc text
)

Thanks for your help.

stanton schmidt
Database Administrator
direct. 920.471.4495  cell 920.660.1828

RGL
GO AHEAD. ASK WHAT IF.
www.RGLlogistics.co m


--------------38FB428AF38474977D3563C2--