Solved

db2 olap functions combining two rows into one

Posted on 2015-02-20
3
180 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 73

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 73

Accepted Solution

by:
sdstuber earned 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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.​
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

21 Experts available now in Live!

Get 1:1 Help Now