Thank you guys!
I'm currently migrating an Oracle database to postgres and have
created tables using the scripts that were readily available. Glad I
can now improve this old system.
On 29/05/07, Gregory Stark <[EMAIL PROTECTED]> wrote:
"Andrew Kroeger" <[EMAIL PROTECTED]> writes:
> Raj A wrote
"Andrew Kroeger" <[EMAIL PROTECTED]> writes:
> Raj A wrote:
>> I have a table
>>
>> CREATE TABLE survey_load
>> (
>> meter_id character(5) NOT NULL,
>> number_of_bays integer NOT NULL,
>> bay_1_use integer,
>> bay_2_use integer,
>> bay_3_use integer,
>> bay_4_use integer,
>> bay_5_use inte
Raj A wrote:
> I have a table
>
> CREATE TABLE survey_load
> (
> meter_id character(5) NOT NULL,
> number_of_bays integer NOT NULL,
> bay_1_use integer,
> bay_2_use integer,
> bay_3_use integer,
> bay_4_use integer,
> bay_5_use integer,
> date date NOT NULL,
> inspection_id integer NOT NU
Scott,
> Unfortunately, your revised query works like a charm except for the
> fact that prd_data."date" - prd2."date" + 1 give incorrect values when
> the year wraps, see in the output below. Need to conditionally
> subtract 88 from the date or use an incrementing count() function
> instead of d
Greg Stark <[EMAIL PROTECTED]> writes:
[ nice example snipped ]
... Also, you'll have to change it to use reals.
That part, at least, can be worked around as of 7.4: use polymorphic
functions. You can declare the functions and aggregate as working on
anyelement/anyarray, and then they will automa
Greg Stark <[EMAIL PROTECTED]> writes:
> [ nice example snipped ]
> ... Also, you'll have to change it to use reals.
That part, at least, can be worked around as of 7.4: use polymorphic
functions. You can declare the functions and aggregate as working on
anyelement/anyarray, and then they will au
Scott Gerhardt <[EMAIL PROTECTED]> writes:
> Hello, I am new to the list, my apology if this question is beyond the scope or
> charter of this list.
>
> My questions is:
> What is the best method to perform an aggregate query to calculate sum() values
> for each distinct wid as in the example be
Scott,
> >> I tried your query but it doesn't seem to work. The interpreter
> >> expects prd2.date to be grouped but this doesn't make sence, see
> >> below:
> >
> > Oh, yeah, darn it.
> >
> > Hmmm ... maybe you could explain the purpose of selecting just 6?
> > This query
> > is going to get a *
Scott,
> > SELECT wid,
> > (SELECT SUM(oil) FROM prd_data pd2
> > WHERE pd2.wid = prd_data.wid ORDER BY "date" LIMIT 6) as tot_oil,
> > (SELECT SUM(hours) FROM prd_data pd2
> > WHERE pd2.wid = prd_data.wid ORDER BY "date" LIMIT 6) as tot_hours
> > FROM prd_data
> > ORDER BY wid;
shouldn't take that long, I would think.
You have indexes on wid and date?
Troy
>
> Hello, I am new to the list, my apology if this question is beyond the
> scope or charter of this list.
>
> My questions is:
> What is the best method to perform an aggregate query to calculate
> sum() values
Scott,
> Hello, I am new to the list, my apology if this question is beyond the
> scope or charter of this list.
We have a charter? Why didn't anyone tell me?
> My questions is:
> What is the best method to perform an aggregate query to calculate
> sum() values for each distinct wid as in t
11 matches
Mail list logo