Re: [SQL] skip weekends

2002-06-20 Thread Rudi Starcevic
Hello, Nice reply Josh. I wouldn't call your solution 'ugly' at all. It's an excellent example of a real world need for Postgresql functions. I've also been looking at other functions at http://www.brasileiro.net/postgres/cookbook/. I noticed your name amongst the author's -- nice one -- keep u

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-20 Thread Joe Conway
Josh Berkus wrote: > Folks, > > Hey, I need to write a date calculation function that calculates the > date after a number of *workdays* from a specific date. I pretty > much have the "skip holidays" part nailed down, but I don't have a > really good way to skip all weekends in the calucla

[SQL] SQL Challenge: Skip Weekends

2002-06-20 Thread Josh Berkus
Folks, Hey, I need to write a date calculation function that calculates the date after a number of *workdays* from a specific date. I pretty much have the "skip holidays" part nailed down, but I don't have a really good way to skip all weekends in the caluclation. Here's the ideas I've come

Re: [SQL] how to sort a birthday list ?

2002-06-20 Thread Josh Berkus
Michael, > SELECT * > FROM Persons > WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EXTRACT( YEAR FROM AGE( > CURRENT_DATE+60, dateofbirth ) ) > > ... but how do I sort the list ? Easy: SELECT person_name, person_department, EXTRACT( YEAR FROM AGE(dateofbirth) ) as their_age FROM Persons WH

Re: [SQL] SQL performance issue with PostgreSQL compared to

2002-06-20 Thread Josh Berkus
Achilleus, > > > The pgsql db is indexed on the > > > 'authuser' field, and I've run 'analyze logfile'. > > > > He also needs to index the bytes field and the traffic field. And run > ^^^ > > Index on an aggregate function??? > > I thoug

Re: [SQL] how to sort a birthday list ?

2002-06-20 Thread David Stanaway
On Thu, 2002-06-20 at 13:55, Michael Agbaglo wrote: > Hi ! > > there's a nice query for retrieving the people who have their birthday > in the next n days: (taken from Joe Celko's SQL for Smarties, 1st Ed., > p. 76) > > SELECT * > FROM Persons > WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EX

[SQL] how to sort a birthday list ?

2002-06-20 Thread Michael Agbaglo
Hi ! there's a nice query for retrieving the people who have their birthday in the next n days: (taken from Joe Celko's SQL for Smarties, 1st Ed., p. 76) SELECT * FROM Persons WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EXTRACT( YEAR FROM AGE( CURRENT_DATE+60, dateofbirth ) ) ... but how d

Re: [SQL] Tagging rows into collections?

2002-06-20 Thread Richard Huxton
On Wednesday 19 Jun 2002 10:19 pm, Tom Lane wrote: > Steve Wampler <[EMAIL PROTECTED]> writes: > > An event has: timestamp,event_name,list_of_attributes > >The list_of_attributes are simple (string) name,value pairs. > > > > However, although selection performance isn't a priority, the > > a

Re: [SQL] Which one is faster?

2002-06-20 Thread Bruce Momjian
Jan Wieck wrote: > Bruce Momjian wrote: > > > > Wei Weng wrote: > > > Between Using Limit P, S or using a cursor to start from FETCH ABSOLUTE > > > S and FETCH NEXT for P times, which one is faster? > > > > LIMIT is faster because it doesn't need to generate all the result, in > > some cases. >