I built a dynamic query interface form for end users such that they can query any way they like; this is a financial db. One of the options is to query on date. If the user selects a date range, the sum of unique accts is aggregated by date. If the user wants to see the sum of a date range, but not return a row for each date within the date range, I need to first aggregate, then query on that aggregated. Querying a query...
Is there a way to combine the following into one query? In one shot?
Here's the SQL of the first:
SELECT DISTINCT tbl_GL.Months, tbl_Physician.LastName, tbl_GL.Account, tbl_GL.Amount
FROM tbl_Physician INNER JOIN tbl_GL ON tbl_Physician.PhysicianID = tbl_GL.PhysicianID
GROUP BY tbl_GL.Months, tbl_Physician.LastName, tbl_GL.Account, tbl_GL.Amount;
Then the other:
SELECT Example.LastName, Example.Account, Sum(Example.Amount) AS SumOfAmount
FROM Example
GROUP BY Example.LastName, Example.Account;
Thanks