Re: [SQL] About Div

2006-07-25 Thread Ross Johnson
Otniel Michael wrote: Mr. Aaron. I am sorry, your solution didn't match in my case. Example for your solution : A = 1 B = 1 C = 1 D = 1 E = 1 F = 1 G = 4 G have 4 candy. Its too much for G. In my case, the solution is : A = 1 B = 1 C = 1 D = 1 E = 2 F = 2 G = 2 The extra candy is given to thr

Re: [SQL] Multi-table insert using RULE - how to handle id?

2006-07-19 Thread Ross Johnson
value generated by nextval(seqX) in the same session, so there is no race between your session and other sessions that may be using the same sequence. So it's safe to let the insert trigger the next value automatically, and then call currval(). In contrast, don't use lastval()

Re: [SQL] set return function is returning a single record,

2006-04-28 Thread Ross Johnson
On Fri, 2006-04-28 at 12:56 +0200, A. Kretschmer wrote: > am 28.04.2006, um 16:14:10 +0530 mailte Penchalaiah P. folgendes: > > 4) The following is the function that retrieves the records from pss : > > > > CREATE or replace FUNCTION ftoc9() RETURNS setof structrankmaster2 > > LANGUAGE 'plpgsq

Re: [SQL] how to use recursion to find end nodes of a tree

2006-04-10 Thread Ross Johnson
On Mon, 2006-04-10 at 16:09 +0100, [EMAIL PROTECTED] wrote: > Hello All, > > I have been having a really hard time trying to come up with a pl/pgsql > recursive function to returns the end nodes of a tree. > Here is an example table definition: > > CREATE TABLE parent_child ( > parent_id intege

Re: [SQL] concatenation with a null column (using ||) nulls the

2006-04-10 Thread Ross Johnson
On Mon, 2006-04-10 at 14:36 -0700, Neil Harkins wrote: > inventory=> SELECT cabinets_name, cabinets_description > FROM cabinets WHERE cabinets_datacenters = 2; > cabinets_name | cabinets_description > ---+-- > 548-4th-Cab2 | > 548-4th-RR1 | > 548-4th-RR2 |

Re: [SQL] cross tables, SELECT expressions, and GROUP BY problem

2006-04-02 Thread Ross Johnson
Following up my own question again, I've realised my error and solved my problem - in the interests of completing this thread, the working query (two versions) can be found below... On Sun, 2006-04-02 at 18:00 +1000, Ross Johnson wrote: > On Sun, 2006-04-02 at 16:43 +1000, Ross Johns

Re: [SQL] cross tables, SELECT expressions, and GROUP BY problem

2006-04-02 Thread Ross Johnson
On Sun, 2006-04-02 at 16:43 +1000, Ross Johnson wrote: > Hi, > > I'm relatively stretched when it comes to SQL but I'm getting there. I > have a question though: > > Thanks to various web sites I've succeeded in creating simple cross > tables in Postgre

[SQL] cross tables, SELECT expressions, and GROUP BY problem

2006-04-01 Thread Ross Johnson
"Diptera (Other)" ... I want to GROUP on the "Ranking" field as well so that all rows with the same "Ranking" value are SUMmed. That is, I'm trying to achieve the following: Ranking Taxa011 012 013 22