Re: [SQL] Add calculated fields from one table to other table

2006-11-02 Thread Richard Broersma Jr
> I am sending you the create statement of tables & few insert statements as > well. Hope this > helps to solve the problem. where are the insert statements? ;) > > CREATE TABLE ticks > ( > tick_id int8 NOT NULL DEFAULT nextval(('ticks_s'::text)::regclass), > ric varchar(30) NOT NUL

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread roopa perumalraja
Hi Richard,   Thanks a lot.   I am sending you the create statement of tables & few insert statements as well. Hope this helps to solve the problem.   CREATE TABLE ticks(  tick_id int8 NOT NULL DEFAULT nextval(('ticks_s'::text)::regclass),  ric varchar(30) NOT NULL,  tick_date date NOT NULL, 

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread Richard Broersma Jr
> Hi Richard, > > Thanks a lot. I still am not able to get the result for all the rics in the > ticks table but I > am able to get the result for a particular ric. > > Can you help me with getting the result for all the rics in the ticks table > > Thanks > Roopa Could you send

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread roopa perumalraja
Hi Richard,   Thanks a lot. I still am not able to get the result for all the rics in the ticks table but I am able to get the result for a particular ric.   Can you help me with getting the result for all the rics in the ticks table   Thanks RoopaRichard Broersma Jr <[EMAIL PROTECTED]> wrot

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread Richard Broersma Jr
> Thanks for your help. That does make sense, but I am not able to get the > result what I wanted > exactly. Let me explain you. > > I have ticks table in which I have columns like ric, tick_time, price & > volume. The times > table has just one column with times_time which has time data

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread roopa perumalraja
Hi Richard,   Thanks for your help. That does make sense, but I am not able to get the result what I wanted exactly. Let me explain you.   I have ticks table in which I have columns like ric, tick_time, price & volume. The times table has just one column with times_time which has time data for

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread Moiz Kothari
Roopa,Why dont you try putting in some case or decode with your first field, so incase if nothing is returned you explicitly make it 'A' kinds. Regards,Moiz Kothari On 10/31/06, roopa perumalraja <[EMAIL PROTECTED]> wrote: Hi   Thanks a lot for your help. The query which you suggested gives me a

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread Richard Broersma Jr
> select foo.ric, tm.times_time, count(tk.*), avg(tk.price), > sum(tk.price*tk.volume)/sum(tk.volume), sum(tk.volume) from (select distinct > ric from ticks) as > foo, times tm left join ticks tk on tk.tick_time >= tm.times_time and > tk.tick_time < > (tm.times_time + '1 minute' :: interval)::t

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread roopa perumalraja
Hi   Thanks a lot for your help. The query which you suggested goes like this   select foo.ric, tm.times_time, count(tk.*), avg(tk.price), sum(tk.price*tk.volume)/sum(tk.volume), sum(tk.volume) from (select distinct ric from ticks_20060404 where ric = 'TRB') as foo, times tm left join ticks_20

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread roopa perumalraja
Hi   Thanks a lot for your help. The query which you suggested gives me a result like this   A  | 12:00| 12 | 64.99 | 63.99     | 12:01 | 0 | | A | 12:02 | 5 | 36.99 | 32.99   but I wanted the result to look like this  A  | 12:00| 12 | 64.99 | 63.99 A | 12:01 | 0 | | A | 12:02 | 5 |

Re: [SQL] Add calculated fields from one table to other table

2006-10-29 Thread Richard Broersma Jr
> Thanks a lot for your help. The query does work, but now I have a problem. > The query goes like > this: > > select tk.ric, tm.timeseries_time, count(tk.*), avg(tk.price), > sum(tk.price*tk.volume)/sum(tk.volume), sum(tk.volume) > from ticks tk, timeseries tm where tk.tick_time >= tm.t

Re: [SQL] Add calculated fields from one table to other table

2006-10-29 Thread Moiz Kothari
Hi Roopa,If your timeseries table has records for all minutes, then you should outer join both tables so as to get the desired results you are looking for... try doing this.select tk.ric, tm.timeseries_time , count(tk.*), avg(tk.price),sum(tk.price*tk.volume)/sum(tk.volume), sum(tk.volume)from tick

Re: [SQL] Add calculated fields from one table to other table

2006-10-29 Thread roopa perumalraja
Hi   Thanks a lot for your immediate reply. I want to explain more about it. The ticks table has many rows in each minute and timeseries table has 1 minute increment data. And the query is as mentioned below, which just displays the result for the minutes in which the tick data exists. but i wou

Re: [SQL] Add calculated fields from one table to other table

2006-10-29 Thread roopa perumalraja
Hi   Thanks a lot for your help. The query does work, but now I have a problem. The query goes like this:   select tk.ric, tm.timeseries_time, count(tk.*), avg(tk.price), sum(tk.price*tk.volume)/sum(tk.volume), sum(tk.volume) from ticks tk, timeseries tm where tk.tick_time >= tm.timeseries_tim

Re: [SQL] Add calculated fields from one table to other table

2006-10-28 Thread chester c young
roopa perumalraja <[EMAIL PROTECTED]> wrote: Hi   I have two tables. Tick table has fields like ticker, time, price & volume and Timeseries table has fields like ticker, time, avg_price, avg_volume.   The time field in Timeseries table is different from time in tick table, its the timeseries fo

Re: [SQL] Add calculated fields from one table to other table

2006-10-26 Thread Richard Broersma Jr
> I have two tables. Tick table has fields like ticker, time, price & volume > and Timeseries > table has fields like ticker, time, avg_price, avg_volume. > > The time field in Timeseries table is different from time in tick table, > its the timeseries > for every minute. Now I want to ca

Re: [SQL] Add calculated fields from one table to other table

2006-10-25 Thread Aaron Bono
On 10/25/06, roopa perumalraja <[EMAIL PROTECTED]> wrote: Hi   I have two tables. Tick table has fields like ticker, time, price & volume and Timeseries table has fields like ticker, time, avg_price, avg_volume.   The time field in Timeseries table is different from time in tick table, its the

[SQL] Add calculated fields from one table to other table

2006-10-25 Thread roopa perumalraja
Hi   I have two tables. Tick table has fields like ticker, time, price & volume and Timeseries table has fields like ticker, time, avg_price, avg_volume.   The time field in Timeseries table is different from time in tick table, its the timeseries for every minute. Now I want to calculate the a