Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 0BC8D476103 for ; Fri, 14 Jun 2002 11:32:58 -0400 (EDT) Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) by postgresql.org (Postfix) with ESMTP id AF78D47594A for ; Fri, 14 Jun 2002 11:25:32 -0400 (EDT) Received: from nick (bilbo.ontko.com [199.164.165.101]) by shire.ontko.com (8.9.3/8.9.3/Debian 8.9.3-21) with SMTP id KAA15269; Fri, 14 Jun 2002 10:25:08 -0500 X-Authentication-Warning: shire.ontko.com: Host bilbo.ontko.com [199.164.165.101] claimed to be nick Reply-To: From: "Nick Fankhauser" To: "Robson Martins" , Subject: Re: Divide Date with integer Date: Fri, 14 Jun 2002 10:22:00 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <000a01c213b1$689f3a80$3a3c620a@catnet.com.br> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200206/100 X-Sequence-Number: 4535 Robson- two suggestions- This is an SQL question, so it should be posted to the pgsql-sql list, not the admin list. You can get information about subscribing to the pgsql-sql list here: http://www.postgresql.org/idocs/index.php?sql-expressions.html To find information on your own, the idocs are a great resource. You can find them here: http://www.postgresql.org/idocs/ Searching on "cast" from the idocs page led me to this page, which will show you how to do the explicit cast required to make the expression you sent at least syntactically correct: http://www.postgresql.org/idocs/index.php?sql-expressions.html Regards, -Nick -------------------------------------------------------------------------- Nick Fankhauser nickf@ontko.com Phone 1.765.935.4283 Fax 1.765.962.9788 Ray Ontko & Co. Software Consulting Services http://www.ontko.com/ -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Robson Martins Sent: Friday, June 14, 2002 9:39 AM To: pgsql-admin@postgresql.org Subject: [ADMIN] Divide Date with interger As to divide one i number int number with date Exemplo: > Select Max(RazaoSocial) As mRazaoSocial, Max(Endereco) As mEndereco, Max(Bairro) As mBairro, Max(Cidade) As mCidade, Max(CEP) As mCEP, Max(UF) As mUF, ('(' || Max(DDD) || ') ' || Max(Fone1)) As mFone, Max(Data) As mData, Sum(Qtde) As mQtde, DescCor As mCor FROM Movimento, Clientes, Cores WHERE Movimento.CGC = Clientes.CGCCli And Clientes.TipoCli = 'N' And Clientes.CodCli > 1 And (Clientes.Class = 'A' Or Clientes.Class = 'B' Or Clientes.Class = 'C') And Movimento.CodCor = Cores.CodCor And Movimento.Data >=(current_date-(30*4)) And Movimento.CodProduto = '2491' And Clientes.UF = 'SP' Group By CGCCli, DescCor Order By (Sum(Qtde) / (current_date + 1 -Max(Data))) Desc Error: ERROR: Unable to identify an operator '/' for types 'numeric' and 'interval' You will have to retype this query using an explicit cast Regards.