Received: from post.gateone.com (qmailr@post.gateone.com [204.244.205.25]) by hub.org (8.8.8/8.7.5) with SMTP id AAA20627 for ; Fri, 24 Jul 1998 00:18:50 -0400 (EDT) Received: (qmail 413 invoked from network); 24 Jul 1998 04:18:44 -0000 Received: from trevor.gateone.com (HELO wizard.ca) (204.244.205.12) by mail.gateone.com with SMTP; 24 Jul 1998 04:18:44 -0000 Message-ID: <35B80B2E.CE3B1C3C@wizard.ca> Date: Thu, 23 Jul 1998 21:18:54 -0700 From: The Web Administrator Reply-To: wwwadmin@wizard.ca X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 To: PGsql Subject: Sub Queries Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a little SQL puzzle I am trying to work out.. This is an a/r question... I have various transactions with date,amount, group, and userid, (amongst others) I need to get a query that will return totals as single rows in the following format Users | AR current | AR over 30 | AR over 60 | AR over 90 | Total AR It will be returned grouped by group User is count( DISTINCT userid) AR_current is a total of all amounts in the rows whose dates are in this month.. AR_over 30 is with dates in the preceding month etc.. And AR_total is the total of all amounts in all the rows of the table. I am trying to use several subqueries each returning a sum of the applicable balances I cannot seem to get it to work.. Any other suggestions on how to handle this issue? Table has rows like userid -- from which I can also get the group dateposted amount Looking for rows returned as groupa, number of users with records in this table in this group, dollar figure who's transactions are in a certain date range(1), dollars in date range (2), in date range (3), total of all transactions in that group. groupb, etc.. groupc, etc.. -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael - System Administrator Working in Cheap Canadian Dollars Unix Administration - WebSite Hosting - Network Services - Programming Wizard Internet Services - TechnoWizard Computers - Wizard Tower TechnoServices ------------------------------------------------------------------------------ (604) 589-0037 Beautiful British Columbia, Canada ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++