Re: [SQL] grouping subsets

2010-07-31 Thread Rainer Stengele
4267067 298690 2010-07-05 00:59:15.187 >>>>>> 2010-07-05 01:32:48.300 1726 3212 1428 333 >>>>>> 4270023 298734 2010-07-05 01:59:02.497 >>>>>> 2010-07-05 02:32:48.780

Re: [SQL] grouping subsets

2010-07-30 Thread Joshua Tolley
On Thu, Jul 22, 2010 at 11:31:23AM +, Tim Landscheidt wrote: > Richard Huxton wrote: > > >>> What I want to get is the values grouped by "subset", where a subset is a > >>> set of rows with identical column until the colum changes. > >>> Is there a way to get > > >>> | 2 | B | > >>> | 4 | C

Re: [SQL] grouping subsets

2010-07-30 Thread Oliveiros d'Azevedo Cristina
b.c) = '-1 day'::interval) ) ) th ON fo.a = th.b AND fo.b <= th.c GROUP BY fo.parcela,fo.a,fo.b,fo.c ) tudo GROUP BY tudo.a,tudo.c,tudo.d To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, having a table similar to | 1 | B | [2010-07-15 Do] | |

Re: [SQL] grouping subsets

2010-07-30 Thread Rainer Stengele
of the item >>>> 5. Column: ID R >>>> 6. Column: ID L >>>> 7. Column: ID B >>>> 8. Column: Sum of components >>>> >>>> Requirement: >>>> Sum over all components (from column 8) for each combination of ID R, ID >&

Re: [SQL] grouping subsets

2010-07-29 Thread Oliveiros d'Azevedo Cristina
le b ON (b.b <> a.b) AND ((age(a.c,b.c) = '-1 day'::interval) ) ) th ON fo.a = th.b AND fo.b <= th.c GROUP BY fo.parcela,fo.a,fo.b,fo.c ) tudo GROUP BY tudo.a,tudo.c,tudo.d To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, having a table simi

Re: [SQL] grouping subsets

2010-07-29 Thread Rainer Stengele
a while, so I don't know if you are still interested in this >>> problem or if you, in the meantime, found yourself a solution, >>> but I've tried this on a local copy of the example you provided and it >>> seems to work. >>> >>> The prob

Re: [SQL] grouping subsets

2010-07-29 Thread Oliveiros d'Azevedo Cristina
,fo.a,fo.b,fo.c ) tudo GROUP BY tudo.a,tudo.c,tudo.d To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, having a table similar to | 1 | B | [2010-07-15 Do] | | 1 | B | [2010-07-16 Fr] | |---+---+-| | 2 | C | [2010-07-17 Sa] | | 2 | C | [2010-07-1

Re: [SQL] grouping subsets

2010-07-29 Thread Rainer Stengele
OUP BY se.a,se.b,se.c > ) fo > LEFT JOIN > ( > SELECT a.* > FROM yourTable a > JOIN yourTable b > ON (b.b <> a.b) > AND ((age(a.c,b.c) = '-1 day'::interval) > ) > ) th > ON fo.a = th.b > AND fo.b <= th.c > GROUP BY fo.parcela,fo.a,fo.b,fo.c >

Re: [SQL] grouping subsets

2010-07-27 Thread Oliveiros d'Azevedo Cristina
l) ) ) th ON fo.a = th.b AND fo.b <= th.c GROUP BY fo.parcela,fo.a,fo.b,fo.c ) tudo GROUP BY tudo.a,tudo.c,tudo.d To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, having a table similar to | 1 | B | [2010-07-15 Do] | | 1 | B | [2010-07-16 Fr] | |---+---+-

Re: [SQL] grouping subsets

2010-07-22 Thread Tim Landscheidt
Rainer Stengele wrote: > yes, the date is always incremented - but anyway the date > column is not really the point! Actually the first tow > columns are relevant. I want them gouped together as > indicated, adding up column 1 in the blocks with identical > second column, but not adding up over a

Re: [SQL] grouping subsets

2010-07-22 Thread Rainer Stengele
gt; The dates always follow that sequential pattern? > > Or can be holes on the dates sequence? > > Best, > Oliveiros > > - Original Message - From: "Rainer Stengele" > > To: > Sent: Thursday, July 22, 2010 9:09 AM > Subject: [SQL] grouping s

Re: [SQL] grouping subsets

2010-07-22 Thread Oliveiros d'Azevedo Cristina
Howdy, Rainer. Please advice me, The dates always follow that sequential pattern? Or can be holes on the dates sequence? Best, Oliveiros - Original Message - From: "Rainer Stengele" To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, havi

Re: [SQL] grouping subsets

2010-07-22 Thread Tim Landscheidt
Richard Huxton wrote: >>> What I want to get is the values grouped by "subset", where a subset is a >>> set of rows with identical column until the colum changes. >>> Is there a way to get >>> | 2 | B | >>> | 4 | C | >>> | 4 | B | >>> | 3 | D | >>> by SQL only? >> I think, the problem is that

Re: [SQL] grouping subsets

2010-07-22 Thread Richard Huxton
On 22/07/10 11:02, A. Kretschmer wrote: In response to Rainer Stengele : What I want to get is the values grouped by "subset", where a subset is a set of rows with identical column until the colum changes. Is there a way to get | 2 | B | | 4 | C | | 4 | B | | 3 | D | by SQL only? I think, t

Re: [SQL] grouping subsets

2010-07-22 Thread A. Kretschmer
In response to Rainer Stengele : > Hi, > > having a table similar to > > | 1 | B | [2010-07-15 Do] | > | 1 | B | [2010-07-16 Fr] | > |---+---+-| > | 2 | C | [2010-07-17 Sa] | > | 2 | C | [2010-07-18 So] | > |---+---+-| > | 1 | B | [2010-07-19 Mo] | > | 1 | B | [201

[SQL] grouping subsets

2010-07-22 Thread Rainer Stengele
Hi, having a table similar to | 1 | B | [2010-07-15 Do] | | 1 | B | [2010-07-16 Fr] | |---+---+-| | 2 | C | [2010-07-17 Sa] | | 2 | C | [2010-07-18 So] | |---+---+-| | 1 | B | [2010-07-19 Mo] | | 1 | B | [2010-07-20 Di] | | 1 | B | [2010-07-21 Mi] | | 1 | B | [2010

Fwd: [SQL] grouping/clustering query

2008-10-27 Thread Osvaldo Kussama
I forgot the list. -- Forwarded message -- From: Osvaldo Kussama <[EMAIL PROTECTED]> Date: Mon, 27 Oct 2008 12:28:57 -0200 Subject: Re: [SQL] grouping/clustering query To: David Garamond <[EMAIL PROTECTED]> 2008/10/24, David Garamond <[EMAIL PROTECTED]>:

Re: [SQL] grouping/clustering query

2008-10-24 Thread David Garamond
Tony, Joe, Steve, Thanks for the follow-ups. Yes, the problem is related to double-entry accounting, where one needs to balance total debit and credit (payments and invoices) in each journal/transaction. Due to time constraint, I ended up doing this in the client-side programming language, since

Re: [SQL] grouping/clustering query

2008-10-24 Thread Tony Wasson
On Fri, Oct 24, 2008 at 10:24 AM, Tony Wasson <[EMAIL PROTECTED]> wrote: > On Fri, Oct 24, 2008 at 8:04 AM, Steve Midgley <[EMAIL PROTECTED]> wrote: >> At 11:28 AM 10/23/2008, Joe wrote: >>> >>> Steve Midgley wrote: > > # (invoiceid, txid) > (A, 1) > (A, 3) > (B, 1) > (B, 2)

Re: [SQL] grouping/clustering query

2008-10-24 Thread Tony Wasson
On Fri, Oct 24, 2008 at 8:04 AM, Steve Midgley <[EMAIL PROTECTED]> wrote: > At 11:28 AM 10/23/2008, Joe wrote: >> >> Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalli

Re: [SQL] grouping/clustering query

2008-10-24 Thread Oliveiros Cristina
From: "Steve Midgley" <[EMAIL PROTECTED]> To: "Joe" <[EMAIL PROTECTED]> Cc: ; "David Garamond" <[EMAIL PROTECTED]> Sent: Friday, October 24, 2008 4:04 PM Subject: Re: [SQL] grouping/clustering query At 11:28 AM 10/23/2008, Joe wrote: Steve Midgle

Re: [SQL] grouping/clustering query

2008-10-24 Thread Steve Midgley
At 11:28 AM 10/23/2008, Joe wrote: Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalling, I need to group/cluster this together. Is there a SQL query that can generate this output: # (journal: invoiceids, txids) [A,B] , [1,2,3

Re: [SQL] grouping/clustering query

2008-10-23 Thread Joe
Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalling, I need to group/cluster this together. Is there a SQL query that can generate this output: # (journal: invoiceids, txids) [A,B] , [1,2,3] [C], [5] [D], [6,7] [E,F], [8] Hi

Re: [SQL] grouping/clustering query

2008-10-23 Thread Steve Midgley
At 10:20 PM 10/22/2008, you wrote: Message-ID: <[EMAIL PROTECTED]> Date: Wed, 22 Oct 2008 12:14:49 +0700 From: "David Garamond" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Subject: grouping/clustering query X-Archive-Number: 200810/89 X-Sequence-Number: 31731 Dear all, I have an invoices

[SQL] grouping/clustering query

2008-10-21 Thread David Garamond
Dear all, I have an invoices (inv) table and bank transaction (tx) table. There's also the payment table which is a many-to-many relation between the former two tables, because each invoice can be paid by one or more bank transactions, and each bank transaction can pay for one or more invoices. Ex

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread Jim C. Nasby
On Thu, Oct 19, 2006 at 01:51:55PM +0200, Mezei Zolt??n wrote: > > Hi, > I didn't really know what subject I should give. > I have a table like this one: > 2006.10.01.Bela10 > 2006.10.01.Aladar9 > 2006.10.01.Cecil8 > 2006.10.01.Dezso7 > 2006.10.01.Elemer6 >

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread Woody Woodring
-- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A. Kretschmer Sent: Thursday, October 19, 2006 10:18 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Grouping by day, limiting amounts am Thu, dem 19.10.2006, um 6:55:41 -0700 mailte chester c young folgendes: > --- "A. Kret

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread A. Kretschmer
am Thu, dem 19.10.2006, um 6:55:41 -0700 mailte chester c young folgendes: > --- "A. Kretschmer" <[EMAIL PROTECTED]> wrote: > > > > I would like to select the 3 (or 10) names with the most votes for > > each day. > > > > > > Any suggestions on how can it be done easily? > > Am I misunderstandi

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread A. Kretschmer
am Thu, dem 19.10.2006, um 13:51:55 +0200 mailte Mezei Zoltán folgendes: > Hi, > > I didn't really know what subject I should give. > > I have a table like this one: > > 2006.10.01.    Bela    10 > 2006.10.01.    Aladar    9 > 2006.10.01.    Cecil    8 > 2006.10.01.    Dezso    7 > 2006.10.01.

[SQL] Grouping by day, limiting amounts

2006-10-19 Thread Mezei Zoltán
Hi, I didn't really know what subject I should give. I have a table like this one: 2006.10.01.    Bela    10 2006.10.01.    Aladar    9 2006.10.01.    Cecil    8 2006.10.01.    Dezso    7 2006.10.01.    Elemer    6 2006.10.02.    Bela    11 2006.10.02.    Aladar    10 2006.10.02.    Cecil  

Re: [SQL] Grouping Too Closely

2005-06-24 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > 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. Then perhaps just: SELECT fkey, seq2, min(seq1) FROM my_table WHERE seq2 > 2 GROUP BY fk

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 3

Re: [SQL] Grouping Too Closely

2005-06-24 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > What I'd like to be able to do is select all records corresponding to > the minimum value of seq1 for each value of seq2 corresponding to a > given fkey (with a lower bound on the value of seq2). I'm not sure how uid figures in, but would this do

Re: [SQL] Grouping Too Closely

2005-06-23 Thread Russell Simpkins
I'm not sure if this is the best thing to do in all occasions, but I have found a great speed increase using unions over group by. select fkey, uid, seq2 from mytable where seq2 > 2 and seq1 = ( select min(seq1) from mytable); union select fkey, uid, seq2 from mytable where seq2 > 2 and seq1 =

[SQL] Grouping Too Closely

2005-06-23 Thread Thomas F. O'Connell
I have a table that looks like this:CREATE TABLE my_table (    pkey serial PRIMARY KEY,    fkey int NOT NULL REFERENCES my_other_table( pkey ),    uid int NOT NULL REFERENCES user( pkey ),    seq1 int,    seq2 int);Basically, for each fkey that exists in my_table, there is a sequence represented by

[SQL] GROUPing only those rows that do not contain a NULL field?

2005-02-16 Thread Simon Kinsella
Hi I wonder if anyone can help me with a SELECT / GROUP BY problem I'm having. I'm trying to refine a query so that my GROUP BY clause only aggregates rows that have a non-NULL value in one of the fields, leaving other rows 'ungrouped'. An example table, resulting from a LEFT JOIN and subselect o

Re: [SQL] grouping a many to many relation set

2004-12-03 Thread Johan Henselmans
On 2-dec-04, at 3:45, Michael Fuhr wrote: On Wed, Dec 01, 2004 at 06:57:54AM +0100, Johan Henselmans wrote: Richard Huxton wrote: I think what's missing here is the explicit statement of which group these belong in. Without a value to sort/group by, there's nothing for your queries to "get a grip

Re: [SQL] grouping a many to many relation set

2004-12-01 Thread Michael Fuhr
On Wed, Dec 01, 2004 at 06:57:54AM +0100, Johan Henselmans wrote: > Richard Huxton wrote: > > > I think what's missing here is the explicit statement of which group > > these belong in. Without a value to sort/group by, there's nothing for > > your queries to "get a grip on". > > > > So - add a "

Re: [SQL] grouping a many to many relation set

2004-12-01 Thread Johan Henselmans
Richard Huxton wrote: Johan Henselmans wrote: Hi, I am having a problem grouping a many to many relationship with payments and receipts, where a payment can be for multiple receipts, and a receipt can have multiple payments. I got a list of records that are involved in such relations, but now I

Re: [SQL] grouping a many to many relation set

2004-11-30 Thread Richard Huxton
Johan Henselmans wrote: Hi, I am having a problem grouping a many to many relationship with payments and receipts, where a payment can be for multiple receipts, and a receipt can have multiple payments. I got a list of records that are involved in such relations, but now I don't know how to grou

[SQL] grouping a many to many relation set

2004-11-29 Thread Johan Henselmans
Hi, I am having a problem grouping a many to many relationship with payments and receipts, where a payment can be for multiple receipts, and a receipt can have multiple payments. I got a list of records that are involved in such relations, but now I don't know how to group them so that all paym

Re: [SQL] Grouping by week

2004-08-06 Thread Tom Lane
Oliver Elphick <[EMAIL PROTECTED]> writes: > How about: >SELECT EXTRACT(WEEK FROM trans_date + '1 day'::INTERVAL) Note that if trans_date is actually a date, you are much better off just adding an integer to it: SELECT EXTRACT(WEEK FROM trans_date + 1) If you add an interval then the date

Re: [SQL] Grouping by week

2004-08-06 Thread Oliver Elphick
On Fri, 2004-08-06 at 22:29, Caleb Simonyi-Gindele wrote: > I'm using > > SELECT EXTRACT(WEEK FROM trans_date), SUM(tran_amount) ... GROUP BY > trans_date > > and it is being used to group sales results by week. It works really well. > > What I'm wondering is if I can shift the week from a Mo

[SQL] Grouping by week

2004-08-06 Thread Caleb Simonyi-Gindele
I'm using SELECT EXTRACT(WEEK FROM trans_date), SUM(tran_amount) ... GROUP BY trans_date and it is being used to group sales results by week. It works really well. What I'm wondering is if I can shift the week from a Mon-Sun articulation(default with Postgre) to a Sun-Sat sequence. I need it

Re: [SQL] grouping by date

2004-01-08 Thread Robert Creager
When grilled further on (Mon, 05 Jan 2004 17:14:26 +), teknokrat <[EMAIL PROTECTED]> confessed: > How can I group by date given a timestamp column? > I just found this out this weekend. Try 'date_trunc'. Look at secion 9.8.2 of the documentation. I'm using something like: SELECT date_tru

[SQL] grouping by date

2004-01-08 Thread teknokrat
How can I group by date given a timestamp column? thanks ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] grouping and first()

2002-10-25 Thread Chad Thompson
: "peter" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 24, 2002 2:12 AM Subject: [SQL] grouping and first() > Hi, just wondering if anyone can tell me what replaces the first function > in access. > > > Thanks > > PEter > >

[SQL] grouping and first()

2002-10-25 Thread peter
Hi, just wondering if anyone can tell me what replaces the first function in access. Thanks PEter ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] GROUPING

2001-10-20 Thread Esteban Gutierrez Abarzua
On Sat, 13 Oct 2001, Timothy J Hitchens wrote: > It's been a while since I used postgresql but today I have converted one > of my web apps but with one small problem. I goto do a group as > designed and executed in mysql and I get told that this and this must be > part of the aggreate etc I am p

Re: [SQL] GROUPING

2001-10-15 Thread Joel Burton
On Sat, 13 Oct 2001, Timothy J Hitchens wrote: > It's been a while since I used postgresql but today I have converted one > of my web apps but with one small problem. I goto do a group as > designed and executed in mysql and I get told that this and this must be > part of the aggreate etc I am p

Re: [SQL] GROUPING

2001-10-15 Thread Lee Harr
On Sat, 13 Oct 2001 03:32:57 + (UTC), <[EMAIL PROTECTED]> wrote: > It's been a while since I used postgresql but today I have converted one > of my web apps but with one small problem. I goto do a group as > designed and executed in mysql and I get told that this and this must be > part of th

Re: [SQL] GROUPING

2001-10-13 Thread Stephan Szabo
On Sat, 13 Oct 2001, Timothy J Hitchens wrote: > It's been a while since I used postgresql but today I have converted one > of my web apps but with one small problem. I goto do a group as > designed and executed in mysql and I get told that this and this must be > part of the aggreate etc I am p

[SQL] GROUPING

2001-10-12 Thread Timothy J Hitchens
It's been a while since I used postgresql but today I have converted one of my web apps but with one small problem. I goto do a group as designed and executed in mysql and I get told that this and this must be part of the aggreate etc I am puzzled and wonder if someone could bring me up to stratc

Re: [SQL] grouping by date increments

2001-01-23 Thread Tom Lane
"Graham Vickrage" <[EMAIL PROTECTED]> writes: > I have written this successfully but need to get the count in time > increments such as per day/week/month. Perhaps use GROUP BY date_part(...). See stgresql.org/devel-corner/docs/postgres/functions-datetime.htm for doco on date_part().

[SQL] grouping by date increments

2001-01-23 Thread Graham Vickrage
I am trying to write a select statement to count the occurences of a particular string between a set of dates. I have written this successfully but need to get the count in time increments such as per day/week/month. At the moment I am doing a select for each increment seperately but figure that