From: | "David Lloyd-Jones" <david(dot)lloyd-jones(at)attcanada(dot)ca> |
---|---|
To: | "Thomas Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>, "Itai Zukerman" <zukerman(at)math-hat(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Time Aggregates |
Date: | 2000-08-02 15:37:44 |
Message-ID: | 001a01bffc9a$d33544f0$49647bd8@WORKGROUP |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Thomas Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu> replied to:
"Itai Zukerman" <zukerman(at)math-hat(dot)com>
> > I'm currently doing this:
> > SELECT symbol, date_trunc('minute', posted),
> > min(price), max(price), avg(price)
> > FROM trade
> > GROUP BY symbol, date_trunc('minute', posted);
> > to get a list of minute-averages of trade prices. I get the feeling
> > that this is bad form, that I should be doing this some other way. Is
> > that the case?
>
> Looks OK to me. If you are doing this *a lot* (i.e. many more queries
> than inserts), then you might want to set up another column which
> contains date_trunc('minute',posted) to avoid the calculation. Something
> like
>
> create table trade (
> symbol text,
> posted timestamp,
> price integer,
> mpost timestamp
> )
>
> then define a rule to update mpost when posted gets set (haven't done
> that part).
Tom,
I want to have two inputs to a table -- 5 widgets at 6 dollars, nextline,7
widgets at 45 dollars, nextline 1 widget at 4...sort of thing -- and output
to screen the $30, $315, $4 with those last three numbers also going back
into the database.
Is there any way of doing this withing the SQL, or does it have to be
written in a scipt external to the database itself?
Cheers,
-dlj.
From | Date | Subject | |
---|---|---|---|
Next Message | Itai Zukerman | 2000-08-02 15:52:01 | Re: Time Aggregates |
Previous Message | Thomas Lockhart | 2000-08-02 15:27:13 | Re: Time Aggregates |