Solved

INSERT INTO temp table

Posted on 2011-03-11
2
502 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
Comment Utility
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
Comment Utility
thank you very much
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
GRANT, REVOKE, DENY 4 14
Updating ms sql with special characters 8 19
SQL Date Retrival 7 21
Test a query 23 10
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
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 retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

763 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

9 Experts available now in Live!

Get 1:1 Help Now