Solved

INSERT INTO temp table

Posted on 2011-03-11
2
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

696 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