Re: [GENERAL] Return t/f on existence of a join

2007-09-21 Thread Jon Sime
Madison Kelly wrote: I want to create a query that will allow me to say show me all 'foo' rows and tell me if a specific 'baz_id' belongs to it. Normally, I would do this: SELECT foo_id FROM foo; (for each returned row) { # Where '$foo_id' is the current 'foo_id' and '$bar_id'

Re: [GENERAL] Optimising SELECT on a table with one million rows

2007-07-30 Thread Jon Sime
Cultural Sublimation wrote: SELECT comments.comment_id, users.user_name FROM comments, users WHERE comments.comment_story = 100 AND comments.comment_author = users.user_id; The problem is that this query takes a *very* long time. With the said 1,000,000 comments, it needs at least 1100ms on my

Re: [GENERAL] monthly tally of new memberships

2007-07-18 Thread Jon Sime
brian wrote: I'm trying to create a select statement that will show me the number of new memberships or an organisation by date (first of each month). The member table has a date column to reflect when the member was inserted. So far, i've gotten as far as: SELECT applied AS date_applied,

Re: [GENERAL] list all columns in db

2007-06-07 Thread Jon Sime
Jonathan Vanasco wrote: Does anyone have a trick to list all columns in a db ? No trickery, just exploit the availability of the SQL standard information_schema views: select table_schema, table_name, column_name from information_schema.columns where table_schema not in

Re: [GENERAL] Age function

2007-05-14 Thread Jon Sime
Andrus wrote: How to create function which returns persons age in years? Function parameters: ldDob - Day Of birth ldDate - Day where age is returned I tried CREATE OR REPLACE FUNCTION public.age(date, date, out integer) IMMUTABLE AS $_$ SELECT

Re: [GENERAL] Feature request - have postgresql log warning when new sub-release comes out.

2007-04-26 Thread Jon Sime
Leif B. Kristensen wrote: On Thursday 26. April 2007 17:10, Joshua D. Drake wrote: Actually, I've a feeling that it would be trivial to do with just about any existing packaging system ... Yes pretty much every version of Linux, and FreeBSD, heck even Solaris if you are willing to run 8.1.

Re: [GENERAL] OT: schema-sketching software

2007-04-13 Thread Jon Sime
Kynn Jones wrote: Hi. I'm looking for Pg- and OSX-friendly software for generating schema diagrams. It its most basic level, I'm looking for the graphics counterpart of pg_dump -s, although it would be nice if the program could take as input the name of a file containing an arbitrary schema

Re: [GENERAL] SQL - finding next date

2007-04-11 Thread Jon Sime
Raymond O'Donnell wrote: This is probably a very simple one, but I just can't see the answer and it's driving me nuts. I have a table holding details of academic terms, and I need an SQL query such that for any given term I want to find the next term by starting date (or just NULL if there