Solved

*** SQL Combine 2 Queries and Display Rows as Columns

Posted on 2013-06-04
2
311 Views
Last Modified: 2013-06-04
Hello Experts,

I have 2 queries.

1st Query produces:

ID    Status           Qty_BLUE
10    Pending         12
11    Processed      25
12    Completed     14

2nd Query Produces:

ID    Status           Qty_RED
20    Pending          45
21    Processed       31
22    Completed     17

I would like to combine the results from both queries to look like this:

Status           Qty_BLUE    Qty_RED
Pending         12                  45
Processed      25                  31
Completed     14                 17

Your help is GREATLY appreciated!  Thank you!!
0
Comment
Question by:giggul
2 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 500 total points
ID: 39219712
just join the 2 queries on status

SELECT Red.Status, Red.QtyRed, Blue.QtyBlue
FROM
   (SELECT ...) AS Red
INNER JOIN
   (SELECT ...) AS Blue
ON Red.Status = Blue.Status
0
 

Author Comment

by:giggul
ID: 39219814
wow, that was easy.  THANKS !!!!!!!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question