Re: Ideas for query

From: Steve Clark <sclark(at)netwolves(dot)com>
To: rod(at)iol(dot)ie
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Ideas for query
Date: 2011-10-13 18:23:36
Message-ID: 4E972CA8.5000501@netwolves.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/13/2011 08:31 AM, Raymond O'Donnell wrote:
> On 13/10/2011 12:17, Steve Clark wrote:
>> Hello List,
>>
>> I am a not very experienced writing sql and I have a problem I can't
>> readily solve, so
>> I was hoping to get some help from this great list.
>>
>> Here is my problem I have a table that has event data about the status
>> of units in the field. It has
>> many kinds of events one of which has down time information. I have
>> written a query to extract that
>> information and calculate the % downtime. The problem I am having is
>> that if the unit was never down
>> I don't see it in my query, I would like to be able to somehow report it
>> as 100% up.
> The way I'd approach this is to do a LEFT OUTER JOIN between the units
> table and the events table, with the units on the left of the join: this
> way any particular unit will always appear in the result set, and if
> there are no corresponding rows in the events table then you know that
> the unit had 100% uptime.
>
> HTH.
>
> Ray.
>
>
Hi Ray,

Thanks for the response, I am afraid I don't know enough on how to formulate the left outer join
so I have attacked the problem from a different direction. Creating a temporary table with all
the units set to 100% then running my existing query and using the results to update my
temporary table where the unit serial no's match.

Steve

--
Stephen Clark
*NetWolves*
Sr. Software Engineer III
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve(dot)clark(at)netwolves(dot)com
http://www.netwolves.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mark Keisler 2011-10-13 19:47:35 Re: How to make replica and use it when master is down ?
Previous Message Steve Crawford 2011-10-13 18:08:17 Re: Bulk processing & deletion