Re: Setting week starting day (was: Re: [GENERAL] Tabulate data incrementally)

2007-03-08 Thread Alvaro Herrera
Jorge Godoy escribió: > I mean, if I wanted to do the above but instead of Sunday or Monday as the > starting day I'd like using Fridays or Wednesdays... > > Is it possible? Writing a new function shouldn't be too hard -- it's a matter > of truncating the week on a day and shifting the date forw

Setting week starting day (was: Re: [GENERAL] Tabulate data incrementally)

2007-03-08 Thread Jorge Godoy
Richard Huxton writes: > Omar Eljumaily wrote: >> I want to tabulate time data on a weekly basis, but my data is entered on a >> daily basis. >> >> create table time_data >> { >>employee varchar(10), >>_date date, >>job varchar(10), >>amount >> } >> >> So I want to tabulate with a

Re: [GENERAL] Tabulate data incrementally

2007-03-08 Thread Omar Eljumaily
Thanks Alvaro. That's good to know. Actually I was spacing on the need for this. The date_trunc function with group by actually works for me. select sum(amount), date_trunc('week', period_end) as dt from time_data group by dt; Alvaro Herrera wrote: Omar Eljumaily wrote: Thanks Tom and

Re: [GENERAL] Tabulate data incrementally

2007-03-08 Thread Alvaro Herrera
Omar Eljumaily wrote: > Thanks Tom and Richard for the tip on date_trunc. Is it possible in an > sql select statement to create an iterator? Yes, use the generate_series() function. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulti

Re: [GENERAL] Tabulate data incrementally

2007-03-08 Thread Omar Eljumaily
Thanks Tom and Richard for the tip on date_trunc. Is it possible in an sql select statement to create an iterator? For instance select myItFunc(1,10); would give 1,2,3,4,5,6,7,8,9,10 I'm a bit embarrassed that I don't know how to do this. My understanding of sql functions is that not bein

Re: [GENERAL] Tabulate data incrementally

2007-03-08 Thread Richard Huxton
Omar Eljumaily wrote: I want to tabulate time data on a weekly basis, but my data is entered on a daily basis. create table time_data { employee varchar(10), _date date, job varchar(10), amount } So I want to tabulate with a single sql command. Is that possible? Try one of these

Re: [GENERAL] Tabulate data incrementally

2007-03-08 Thread Tom Lane
Omar Eljumaily <[EMAIL PROTECTED]> writes: > I want to tabulate time data on a weekly basis, but my data is entered > on a daily basis. Something involving GROUP BY date_trunc('week', _date) might work for you, if your definition of week boundaries matches date_trunc's. If not, you could probably

[GENERAL] Tabulate data incrementally

2007-03-08 Thread Omar Eljumaily
I want to tabulate time data on a weekly basis, but my data is entered on a daily basis. create table time_data { employee varchar(10), _date date, job varchar(10), amount } So I want to tabulate with a single sql command. Is that possible? If I had a separate week end table creat