Solved

db2 olap functions combining two rows into one

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SYbase 4 36
Setting Macro in Access to Automate Running an Append at a Certain Time 2 28
SQL Syntax: How to force case sensitive query? 2 44
error in my cursor 5 41
'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 …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

827 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