Advertisement

03.10.2008 at 10:04AM PDT, ID: 23229078
[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!

9.4

Full Outer Joins

Asked by tim_cs in SQL Server 2005, MS SQL Server, SQL Query Syntax

Tags: ,

I have several tables that I'm trying to query from and I need all of the results in one query.  The results I want would look like this

Date, AreaName, Table1.Count, Table2.Count, Table3.Count

Whenever I output the data I will be using Date and AreaName to output it.  My prolem is all of the tables could have data or only one of them could end up having data.  How would I create this query to get these result using full outer joins?  Would I do something like what's in the Attached code?  How else could I create this query?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
select 
      CASE WHEN A.Count IS NULL THEN CASE WHEN B.Count IS NULL THEN C.Date END ELSE B.Date END ELSE A.Date END AS Date, 
      CASE WHEN A.Count IS NULL THEN CASE WHEN B.Count IS NULL THEN C.AreaName END ELSE B.AreaName END ELSE A.AreaName END AS AreaName,
      A.Count, B.Count, C.Count
FROM    table1 A FULL OUTER JOIN 
        table2 B ON A.Date = B.Date AND A.AreaName = B.AreaName FULL OUTER JOIN 
        table3 C ON A.Date = C.Date and A.AreaName = C.AreaName
[+][-]03.10.2008 at 10:11AM PDT, ID: 21088212

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.

 
[+][-]03.10.2008 at 10:27AM PDT, ID: 21088357

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: SQL Server 2005, MS SQL Server, SQL Query Syntax
Tags: SQL 2005, SQL 2005, IE 7
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.11.2008 at 08:18AM PDT, ID: 21096531

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.

 
[+][-]03.11.2008 at 08:51AM PDT, ID: 21096928

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.

 
[+][-]03.11.2008 at 09:57AM PDT, ID: 21097635

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.

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