Solved

db2 olap functions combining two rows into one

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to use SSMS intellisense when querying 5 61
subtract 1 in Access 2003 query 7 39
SQL Error in WHERE Clause 5 42
SQL Server Update Query Streamline 4 14
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

17 Experts available now in Live!

Get 1:1 Help Now