Re: [SQL] Strange join...maybe some improvements???

2005-10-13 Thread Thomas F. O'Connell
What indexes do you have on these tables?And have you ANALYZEd all three recently? --Thomas F. O'ConnellCo-Founder, Information ArchitectSitening, LLCOpen Source Solutions. Optimized Web Development.http://www.sitening.com/110 30th Avenue North, Suite 6Nashville, TN

Re: [SQL] EXECUTE with SELECT INTO variable, or alternatives

2005-09-30 Thread Thomas F. O'Connell
of your options. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-469-5150 615-469-5151 (fax) On Sep 29, 2005, at 1:16 PM, Mario Splivalo wrote: I can assign

Re: [SQL] Searching for results with an unknown amount of data

2005-09-05 Thread Thomas F. O'Connell
how you'd do it without using a PL, but you could still build your IN clause programmatically. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-469

Re: [SQL] Numerical variables in pqsql statements

2005-08-30 Thread Thomas F. O'Connell
Well, browse through this list: http://www.postgresql.org/docs/books/ I can't make any recommendations, as I am fairly familiar with the online documentation, which, when supported by the community, seems to be pretty good. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening

Re: [SQL] Numerical variables in pqsql statements

2005-08-29 Thread Thomas F. O'Connell
know to be safe or passing in safe values generated elsewhere in the application, you're less likely to need to quote your variables explicitly or to build queries dynamically. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http

Re: [SQL] sql function: using set as argument

2005-08-15 Thread Thomas F. O'Connell
Is there a reason not to build it in as a sub-query?E.g., if you have a function get_count( int ): SELECT count(b_column)FROM some_tableWHERE some_field_1 in (    SELECT a_column    FROM a_table    WHERE some_condition)AND some_field_2 = $2; --Thomas F. O'ConnellCo-Founder, Information

Re: [SQL] Grouping Too Closely

2005-06-24 Thread Thomas F. O'Connell
This doesn't give me quite what I'm looking for because I need there to be only one of each possible value of seq2 to be returned for each value of fkey. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110

[SQL] Grouping Too Closely

2005-06-23 Thread Thomas F. O'Connell
seems like it works, but it is abominably slow, running on the order of days across 1.5 million rows rather than the seconds (or preferably milliseconds) I'd prefer.I have this annoying feeling that I'm overlooking a reasonably efficient in-between query.-- Thomas F. O'Connell Co-Founder, Information

Re: [SQL] query

2005-03-21 Thread Thomas F . O'Connell
You should be able to use the CURRENT_DATE function in place of sysdate. You might need to cast the 1 explicitly to an interval. As in: CURRENT_DATE - '1 day'::interval -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite

Re: [SQL] Making NULL entries appear first when ORDER BY field ASC

2005-02-23 Thread Thomas F . O'Connell
Yup. Got it. Wasn't thinking clearly about what expression meant. Thanks! -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Feb 23, 2005, at 2:33 PM, Bruno Wolff III wrote

Re: [SQL] plpgsql functions and NULLs

2005-01-31 Thread Thomas F . O'Connell
As far as I know, you didn't post your actual table definitions (or full queries) earlier, so I'm not exactly sure what you mean. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260

Re: [SQL] How to update dependent tables AND design considerations

2005-01-25 Thread Thomas F . O'Connell
Have you looked at the documentation on triggers? -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Jan 23, 2005, at 11:23 AM, Klaus W. wrote: Hi! Because i got no answer

Re: [SQL] Counting Distinct Records

2004-11-17 Thread Thomas F . O'Connell
. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Nov 17, 2004, at 8:52 AM, Stephan Szabo wrote: On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: Hmm. I was more interested

[SQL] Counting Distinct Records

2004-11-16 Thread Thomas F . O'Connell
? Furthermore, is there a better way of performing this sort of operation in postgres (or just in SQL in general)? Thanks! -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005

Re: [SQL] SQL confusion

2004-10-12 Thread Thomas F . O'Connell
This is untested, but it might be enough to get you started: SELECT namecounter FROM name n WHERE NOT EXISTS ( SELECT 1 FROM name WHERE hh 0 AND famnu = n.famnu ) GROUP BY famnu HAVING birthdate = min( birthdate ); What I'm trying to do here is grab all families

Re: [SQL] help on a query

2004-10-07 Thread Thomas F . O'Connell
A query that should get the job done is: SELECT registration_id FROM registrations r WHERE NOT EXISTS ( SELECT 1 FROM receipts WHERE registration_id = r.registration_id ); There might be a more efficient version with JOINs that don't require a subquery, but this should get

Re: [SQL] Extracting fieldnames from a TABLE

2004-09-01 Thread Thomas F . O'Connell
One way to do this is to use the column_info database handle method. Here's a little perl script that accepts a table name as an argument and returns the column names: #!/usr/bin/perl use DBI; use strict; my( $database, $table ) = @ARGV; my $dbh = DBI-connect( dbi:Pg:dbname=$database, 'postgres'

[SQL] the optimizer and exists

2002-08-29 Thread Thomas F. O'Connell
i think i might've stumbled across a tiny defect in the optimizer. unfortunately, i haven't the knowledge of the code to know where to begin looking at how to address this problem. anyway, consider the following: create table foo( id int2 ); create table bar( id int2

[SQL] using top-level aggregate values in subqueries

2001-04-23 Thread Thomas F. O'Connell
from the docs, i know that if you have two tables, foo and bar, you can write a query such as select f.bling from foo f where f.id = ( select max( b.id ) from bar b where b.bling = i kiss you! ); what i'm wondering is if you need that subquery in two places in a query