Sub Queries
От | The Web Administrator |
---|---|
Тема | Sub Queries |
Дата | |
Msg-id | 35B80B2E.CE3B1C3C@wizard.ca обсуждение исходный текст |
Список | 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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
В списке pgsql-sql по дате отправления: