Advertisement

10.15.2008 at 06:25PM PDT, ID: 23818966
[x]
Attachment Details

Return records from one table whether or not it exists in another table

[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!

9.0
Tags:

Microsoft, SQL Server, 2000

This should be reasonably straightforward, but I am at a loss. Here's the basic set up:
I have 2 tables. One has a listing of brands. The other is a transactions table. I would like to be able to return results for all of the brands during a given time frame (a month in this case) whether or not those brands had any associated transactions during that time frame.

An output of something like this...
Brand Name      Sales
Brand A      0
Brand B      2
Brand C      3
Brand D      0
Brand E      5
Brand F      0
Brand G      0

Unfortunately, my query only returns those brands that actually had activity during that period. In this case, Brands B, C and E. I need to get the other brands, with 0 values, into the result too. What am I missing?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
SELECT
	  cp.recno
	, cp.name
	, SUM(ISNULL(sc.numcruises,0))
	, SUM(ISNULL(sc.numcruisescxl,0))
	, SUM(ISNULL(sc.charges,0))
	, SUM(ISNULL(sc.chargescxl,0))
	, SUM(ISNULL(sc.costs,0))
	, SUM(ISNULL(sc.costscxl,0))
	, SUM(ISNULL(sc.profits,0))
	, SUM(ISNULL(sc.profitscxl,0))
	, SUM(ISNULL(sc.certvalues,0))
	, SUM(ISNULL(sc.certvaluescxl,0))
	, SUM(ISNULL(sc.adjustedprofits,0))
	, SUM(ISNULL(sc.adjustedprofitscxl,0))
	, SUM(ISNULL(sc.insurancecharges,0))
	, SUM(ISNULL(sc.insurancecosts,0))
	, SUM(ISNULL(sc.insuranceprofits,0))
FROM
	content..cobrand_partners cp
	LEFT JOIN customer..salesmaster_cruises sc ON sc.cobrandrecno = cp.recno
WHERE
	sc.transactiondate >= '10/1/2008'
GROUP BY
	cp.recno, cp.name
ORDER BY
	cp.name
 
Accepted Solution by acperkins:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by acperkins:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-46 - Hierarchy / EE_QW_2_20070628