Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

db2 olap functions combining two rows into one

Posted on 2015-02-20
3
Medium Priority
?
228 Views
Last Modified: 2015-02-23
I am trying to find a olap function that will combine two rows into one.  I have a field that I can group by on but the indicators I would like to crosstab.  Combining the two rows into one.  I will attach a sample file.
0
Comment
Question by:centralmike
  • 2
3 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 40621870
i don't see an attachment

you can use xmlagg to pull multiple rows and columns into one value

then use xml parsing function to pull the fields into individual columns within a single row
0
 

Author Comment

by:centralmike
ID: 40621949
I will send again
OLAP-SAMPLE.docx
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 40622067
for something like that, it's even simpler, just do conditional aggregation


  SELECT messge_group_id,
         MAX(CASE WHEN debit_credit_ind = 'D' THEN amount END) debit_amt,
         MAX(CASE WHEN debit_credit_ind = 'C' THEN amount END) credit_amt
    FROM table1
GROUP BY message_group_id
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

885 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