From: | The Web Administrator <wwwadmin(at)wizard(dot)ca> |
---|---|
To: | PGsql <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Sub Queries |
Date: | 1998-07-24 04:18:54 |
Message-ID: | 35B80B2E.CE3B1C3C@wizard.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From | Date | Subject | |
---|---|---|---|
Next Message | Maarten Boekhold | 1998-07-24 07:57:15 | Re: [SQL] How Can I limit the select result ? |
Previous Message | Vadim Mikheev | 1998-07-24 02:35:33 | Re: [SQL] returns opaque |