[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

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-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-30 Thread roopa perumalraja
by tm.timeseries_time,tk.ric order by tk.ric, tm.timeseries_time On 10/30/06, roopa perumalraja < [EMAIL PROTECTED]> wrote: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 increme

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 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-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 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, 

[SQL] Help in altering the column lenght

2006-12-28 Thread roopa perumalraja
Hi all, I am trying to alter the column lenght of the table which has 500 child tables by sql command. alter table ticks alter column qualifiers type varchar(500); the error is ERROR: cannot alter type of a column used by a view or rule DETAIL: rule ticks_insert_20070228

[SQL] Help with sub query

2007-03-18 Thread roopa perumalraja
Hi all, I want the last value from the group of rows. The table 'index_prices' is index_code price_time price XYZ09:45:00 7.5 XYZ09:46:00 7.4 XYZ09:59:00 7.2 XYZ10:00:00 7.3 XYZ10:01:00 7.6 XYZ

[SQL] increment the primary key value without using sequences

2007-07-29 Thread roopa perumalraja
Hi all, I would like to know if its possible to increment the primary key field value of stocks table without using sequences by getting the next value of the pk field from the sequnce table ? insert into stocks (prim_id, date,time, code, price, volume) (select . from temp_stocks

[SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread roopa perumalraja
Hi all, I have a table trans with the data price | volume | date | time ---+++-- 79.87 |500 | 2006-06-01 | 13:30:14.262 79.87 |900 | 2006-06-01 | 13:30:15.375 79.85 |200 | 2006-06-01 | 13:30:17.381 79.85 |500 | 2006-06-01 |

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread roopa perumalraja
cators/myinttick2bar.sql?revision=1.3&view=markup and replace the max / min calculation with a count calculation. Cheers Chris On Wed, August 22, 2007 9:25 am, roopa perumalraja wrote: > Hi all, > > I have a table trans with the data > > price | volume | date | time > : > : >