Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Andreas Kretschmer
Carol Cheung wrote: > Hi, > I have a table called temp > > access_date | active | status > -++ > 2009-02-01 | t | 15 > 2009-02-01 | f | 16 > 2009-02-02 | f | 17 > 2009-02-01 | t | 17 > 2009-02-02 | f | 21 > 2009-

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Tom Lane
Carol Cheung writes: > I tried something like > SELECT to_char(access_date, 'MM') as year_month, count(year_month) > FROM temp GROUP BY year_month ORDER BY year_month; The only problem in what you wrote was the illegal cross-reference from one output column to another. Just use count(*) ins

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Scott Marlowe
On Fri, Feb 27, 2009 at 2:02 PM, Carol Cheung wrote: > Hi, > I have a table called temp > >  access_date | active | status > -++ >  2009-02-01  | t      |     15 >  2009-02-01  | f      |     16 >  2009-02-02  | f      |     17 >  2009-02-01  | t      |     17 >  2009-0

[SQL] counts of groupings by date year-month

2009-02-27 Thread Carol Cheung
Hi, I have a table called temp access_date | active | status -++ 2009-02-01 | t | 15 2009-02-01 | f | 16 2009-02-02 | f | 17 2009-02-01 | t | 17 2009-02-02 | f | 21 2009-01-01 | t | 20 2009-01-01 | t

Re: [SQL] row not deleted but updated (trigger?)

2009-02-27 Thread Igor Neyman
"delete" trigger should return "old". In your code you return "new" for both: "update" and "delete" Igor -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Ivan Sergio Borgonovo Sent: Friday, February 27, 2009 6:56 AM To: pgsql-sq

Re: [SQL] row not deleted but updated (trigger?)

2009-02-27 Thread Ivan Sergio Borgonovo
On Fri, 27 Feb 2009 12:56:06 +0100 Ivan Sergio Borgonovo wrote: > I've: > > create or replace function FT1IDX_catalog_brands_update() returns > trigger as $$ > begin > if(TG_OP='DELETE') then > update catalog_items set > FT1IDX=GetFTIDX('pg_catalog.english', Code, CodeAlt, ISBN, > Name, Au

[SQL] row not deleted but updated (trigger?)

2009-02-27 Thread Ivan Sergio Borgonovo
I've: create or replace function FT1IDX_catalog_brands_update() returns trigger as $$ begin if(TG_OP='DELETE') then update catalog_items set FT1IDX=GetFTIDX('pg_catalog.english', Code, CodeAlt, ISBN, Name, Authors, '') where BrandID=old.BrandID; else if(coalesce(new.Name,'')<>coa