Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Tom Lane
Tim Nelson <[EMAIL PROTECTED]> writes: > I am getting division by zero on a calculated field ( sum(sales) is 0 ) > and I can't find a way around this. I figured out you can't use an > aggregate in a where, and using having the parser must (obviously) > evaluate the select fields before consider

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Berend Tober
Richard Huxton wrote: Tim Nelson wrote: I am getting division by zero on a calculated field ( sum(sales) is 0 ) It's a two-stage process, so you'll want a sub-query. Something like: ... Thanks. That's a cool addition to my bag of tricks. ---(end of broadcast)-

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Andreas Kretschmer
Tim Nelson <[EMAIL PROTECTED]> schrieb: > I am getting division by zero on a calculated field ( sum(sales) is 0 ) and > I can't find a way around this. I figured out you can't use an aggregate > in a where, and using having the parser must (obviously) evaluate the > select fields before consid

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Jerry Sievers
Tim Nelson <[EMAIL PROTECTED]> writes: > I am getting division by zero on a calculated field ( sum(sales) is > 0 ) and I can't find a way around this. I figured out you can't use > an aggregate in a where, and using having the parser must > (obviously) evaluate the select fields before considerin

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Michael Glaesemann
On Oct 19, 2005, at 21:26 , Tim Nelson wrote: I am getting division by zero on a calculated field ( sum(sales) is 0 ) and I can't find a way around this. I figured out you can't use an aggregate in a where, and using having the parser must (obviously) evaluate the select fields before con

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Richard Huxton
Tim Nelson wrote: I am getting division by zero on a calculated field ( sum(sales) is 0 ) It's a two-stage process, so you'll want a sub-query. Something like: SELECT type, tot_sales, tot_cost ((tot_sales * tot_cost / tot_sales) * 100) AS percent FROM ( SELECT type, sum(sales) AS tot

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Sean Davis
On 10/19/05 8:26 AM, "Tim Nelson" <[EMAIL PROTECTED]> wrote: > I am getting division by zero on a calculated field ( sum(sales) is 0 ) > and I can't find a way around this. I figured out you can't use an > aggregate in a where, and using having the parser must (obviously) > evaluate the select fi

Re: [GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Patrick FICHE
36 18 --- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Tim Nelson Sent: mercredi 19 octobre 2005 14:27 To: pgsql-general@postgresql.org Subject: [GENERAL] getting around---division by zero on numeric I am getting division by zero on a calculated

[GENERAL] getting around---division by zero on numeric

2005-10-19 Thread Tim Nelson
I am getting division by zero on a calculated field ( sum(sales) is 0 ) and I can't find a way around this. I figured out you can't use an aggregate in a where, and using having the parser must (obviously) evaluate the select fields before considering teh having clause. Does anyone have a way