X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B2437D1B514 for ; Mon, 10 Nov 2003 17:17:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 40073-09 for ; Mon, 10 Nov 2003 13:17:14 -0400 (AST) Received: from ns.lanterm.net (unknown [208.187.178.11]) by svr1.postgresql.org (Postfix) with ESMTP id 4CDCED1B556 for ; Mon, 10 Nov 2003 13:16:58 -0400 (AST) Received: from Louise ([208.187.178.2]) by ns.lanterm.net (8.11.6/8.11.6) with ESMTP id hAAFv7s26103; Mon, 10 Nov 2003 08:57:07 -0700 From: "Louise Cofield" To: , Subject: Re: Date: Mon, 10 Nov 2003 10:17:00 -0700 Message-ID: <00e401c3a7ae$74146e70$7801a8c0@Louise> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-reply-to: <1068274334.3fac929e1ea16@my.msuiit.edu.ph> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/90 X-Sequence-Number: 15905 You will have to use a WHERE clause or a JOIN in query three, so you will have to include some field, such as itemno, in the result sets of both query1 and query2 on which you can join with where or join. Such as: Select query1.sumofqty as sum1, query2.sumofqty as sum2, query1.sumofqty - query2.sumofqty as remain from query1, query2 where query1. = query2. -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of ronald@my.msuiit.edu.ph Sent: Friday, November 07, 2003 11:52 PM To: pgsql-sql@postgresql.org Subject: [SQL] Hello everyone, Good day! Could anyone help me translate this query in Microsoft Access to Postgresql. I'm having a difficulty. Pls... Query1: SELECT items.description, Sum(supplieditems.qty) AS SumOfqty FROM items INNER JOIN supplieditems ON items.itemno = supplieditems.itemno GROUP BY items.description; Query2: SELECT [items].[description], Sum([customer].[qty]) AS SumOfqty FROM (items INNER JOIN OtherItem ON [items].[itemno]=[OtherItem].[Itemno]) INNER JOIN customer ON [OtherItem].[Itemno]=[customer].[itemcode] GROUP BY [items].[description]; Query3: SELECT [Query1].[SumOfqty], [Query2].[SumOfqty], [Query1]![SumOfqty]-[Query2]![SumOfqty] AS remain FROM Query1, Query2; I have translated Query1 and Query2 in POSTGRESQL but I don't know how to implement Query3. ____________________________________________________________ Are you a student of MSU-IIT? Log on http://my.msuiit.edu.ph and sign up for your My.MSUIIT E-mail Plus account now! Are you an MSU-IIT alumnus? Log on http://www.alumni.msuiit.edu.ph ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster