Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Oracle Pivot

Posted on 2016-10-13
2
Medium Priority
?
91 Views
Last Modified: 2016-10-13
Greeting,

I have a select stmt with the following output.
empID   FirstName  LastName Work_type Rate
00001     John             Smith            RE             20
00001     John             Smith             OT            40
00002     Bob              Jackson         RE              25

I'd like to make the change to get the following output
empID       FirstName     LastName     RE_Rate     OT_Rate
00001          John               Smith               20                40
00002          Bob                Jackson            25

Thanks in advance.
0
Comment
Question by:mrong
[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 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 41842118
untested but try something like this:
select empID, FirstName, LastName,
   max(case when work_type='RE' then rate end) re_rate,
   max(case when work_type='OT' then rate end) ot_rate
from your_table
group by empID, FirstName, LastName


Note:  You cannot have a dynamic number of columns.
0
 

Author Closing Comment

by:mrong
ID: 41842160
Thanks!
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

618 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