Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Nick Barr
Emi Lu wrote: Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Thank you! CREATE OR REPLACE FUNCTION lastday (date,int) RETURNS DATE AS ' DECLARE

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Nick Barr
Emi Lu wrote: Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Thank you! It turns out my original solution was slightly (badly) wrong and was

Re: [GENERAL] Postgresql vs. aggregates

2004-06-10 Thread Nick Barr
Hi, - Original Message - From: Richard Huxton [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Scott Marlowe [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, June 10, 2004 8:03 AM Subject: Re: [GENERAL] Postgresql vs. aggregates [EMAIL PROTECTED] wrote: But that raises an interesting

Re: [GENERAL] Naive schema questions

2004-05-27 Thread Nick Barr
- Original Message - From: Peter Eisentraut [EMAIL PROTECTED] To: Rory Campbell-Lange [EMAIL PROTECTED] Cc: Postgresql General List [EMAIL PROTECTED] Sent: Thursday, May 27, 2004 1:10 PM Subject: Re: [GENERAL] Naive schema questions Am Donnerstag, 27. Mai 2004 13:15 schrieb Rory

Re: [GENERAL] table column information

2004-05-17 Thread Nick Barr
Scot L. Harris wrote: Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0 system. I am writing some php scripts where I want to generate a list of the column names in a particular table that the user selects. I could take the brute force method and hard code the column

Re: [GENERAL] How to move data from 1 database to another?

2004-05-11 Thread Nick Barr
Thomas LeBlanc wrote: Actually, the database db2 has all ready been created, plus the table names are the same, so I can not use pg_dump and restore. INSERT INTO db1.public.tables SELECT * FROM db2.public.table1 Thanks, Thomas From: scott.marlowe [EMAIL PROTECTED] To: Thomas LeBlanc [EMAIL

Re: [GENERAL] Very slow query

2004-05-10 Thread Nick Barr
[snip] Rory Campbell-Lange wrote: SELECT DISTINCT b.n_id as id, b.n_type, CASE b.n_type WHEN 0 THEN 'personal' WHEN 1 THEN 'private' WHEN 2 THEN 'blog' ELSE 'public'

Re: [GENERAL] Mistake in my query or Index Scan on subquery failure?

2004-03-03 Thread Nick Barr
Gellert, Andre wrote: Hello, I have a problem with this simple query : explain select * from ref_artikel a where a.artnr in ( 351275 , 351346 , 293082 ) LIMIT 20 OFFSET 0 ; QUERY PLAN

Re: [GENERAL] INSERTS and Queries

2004-03-01 Thread Nick Barr
C G wrote: Dear All, I can use insert with 'select' if I do this INSERT INTO TABLE t1 (col1) SELECT stuff FROM t2; But I want to insert more than one thing into the table, e.g. INSERT INTO TABLE t1 (col1,col2) SELECT stuff FROM t2 , 100; Any ideas on how I would achieve this? Thanks Colin

Re: [GENERAL] Simple, but VERYuseful enhancement for psql command - or am I

2004-02-27 Thread Nick Barr
Ben wrote: I'm designing a fairly involved database system. As part fo the process, I use the \i [FILE] command a great deal. I set up fairly involved queries, sometimes simply for the purpose of shortening column names so the output is reasonable. For example: SELECT longname AS abbr,othername as

Re: [GENERAL] Inner join question

2004-02-19 Thread Nick Barr
Randall Skelton wrote: Greetings all, I am trying to do what should be a simple join but the tables are large and it is taking a long, long time. I have the feeling that I have stuffed up something in the syntax. Here is what I have: telemetry= select (tq1.timestamp = tq2.timestamp) as

Re: [GENERAL] Forcing a query plan

2003-07-03 Thread Nick Barr
Hi, I am assuming that you already have indexes on the appropriate columns, and do a vacuum analyze and not just a vacuum. Columns I would normally put indexes on are image.imageid-- primary key image.containerid image.state ancestry.containerid ancestry.ancestorid Have you tried