Advertisement

12.20.2007 at 10:27AM PST, ID: 23036541
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

Creating a SQL query to return a sum by month (and display every month even if total is zero)

Asked by jetstar51 in Microsoft Access Database, Databases Miscellaneous, MS SQL Server

Tags: , , , ,

I am creating a form that will allow users to view a summary of trading activity by month.  I created a query which takes the user input (year, sector, min trade size) and returns the sums grouped by months.  One problem that I encountered is having the query return a value for every month, even if there were no trades in the month.

For example, my query as is would return the below:
Month / Year    Volume
6 / 2007           1,000,000
7 / 2007           2,000,000
9 / 2007           3,000,000

But I would like it to return the below:
Month / Year    Volume
6 / 2007           1,000,000
7 / 2007           2,000,000
8 / 2007           0
9 / 2007           3,000,000

I would be willing to have the query group by an actual date (like the first day of the month).  I just want it to show all months in the years selected.  Maybe have it make a temp table?  I am just learning Access and SQL so help with the code (shown) would be amazing.  Please ask questions if I am not clear.

Start Free Trial
1:
2:
3:
4:
SELECT year(Trades.ReportDate) AS TradeYear, Month(Trades.ReportDate) AS TradeMonth, Sum(Trades.Size) AS TotalVolume
FROM (SectorList INNER JOIN CompanyList ON SectorList.SectorID=CompanyList.SectorID) INNER JOIN Trades ON CompanyList.Ticker=Trades.Ticker
WHERE (((Year(Trades.ReportDate))>=Forms!MonthForm!YearInput) And ((Year(Trades.ReportDate))<=Forms!MonthForm!YearInput2) And ((Trades.Size)>=Forms!MonthForm!TradeSizeInput) And ((SectorList.SectorName)=Forms!MonthForm!SectorInput))
GROUP BY year(Trades.ReportDate), Month(Trades.ReportDate);
[+][-]12.20.2007 at 10:31AM PST, ID: 20508808

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.20.2007 at 10:32AM PST, ID: 20508813

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.20.2007 at 12:02PM PST, ID: 20509473

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, Databases Miscellaneous, MS SQL Server
Tags: sql, query, display, sum, month
Sign Up Now!
Solution Provided By: dbbishop
Participating Experts: 3
Solution Grade: B
 
 
[+][-]12.21.2007 at 06:35AM PST, ID: 20513696

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.21.2007 at 12:15PM PST, ID: 20516089

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.21.2007 at 12:49PM PST, ID: 20516266

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 01:04PM PST, ID: 20576826

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 03:41PM PST, ID: 20578272

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 03:59PM PST, ID: 20578400

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 04:04PM PST, ID: 20578451

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 04:10PM PST, ID: 20578493

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 05:31PM PST, ID: 20579039

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628