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 below,
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
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
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 date math
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 for
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;
There is only
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 *lot* uglier if there
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 below, but except
for all wid's (not just WHERE
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 the