Solved

INSERT INTO temp table

Posted on 2011-03-11
2
525 Views
Last Modified: 2012-05-11
Please help,

I have table emp

ID   NAME        QUAL       OJ
1    JOHN             01          1
2    DEREK          01          2
3    SUE                02          1
4    JIM                  02          2
5    DEAN              03         1
6    SUZY              01         1
7    RUTH              02         2
 
I have table qual
ID   QUAL      DESC
1         01             DR
2         02             MR
3         03            VSS  

And I need to get table


OJ   DR  MR VSS
   1      2      1       1  
   2      1      2       0

I need how many DR, MR, VSS are in OJ


P.S. I'm using SQL 2008
Thank you very much
   
0
Comment
Question by:hrvica5
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35107502
select e.oj
   , sum(case when QUAL = '01' then 1 else 0 end) DR
   , sum(case when QUAL = '02' then 1 else 0 end) MR
   , sum(case when QUAL = '03' then 1 else 0 end) VSS
 from emp e
group by e.oj
order by e.oj
0
 

Author Closing Comment

by:hrvica5
ID: 35108155
thank you very much
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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…

825 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