Solved

INSERT INTO temp table

Posted on 2011-03-11
2
515 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

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now