"Unnormalize" table

  • Thread starter Thread starter julius.fuchs
  • Start date Start date
J

julius.fuchs

Hello

I have a table which looks like this:

DRG Patient Costs
==================
A a 10
A b 20
A c 15
B a 30

and so on. Now I have to convert it to something like this:


DRG Costs1 Costs2 Costs3
============================
A 10 20 15
B 30

Very ugly but I need it this way for Excel.
How can I do that?
 
julius.fuchs said:
Hello

I have a table which looks like this:

DRG Patient Costs
==================
A a 10
A b 20
A c 15
B a 30

and so on. Now I have to convert it to something like this:


DRG Costs1 Costs2 Costs3
============================
A 10 20 15
B 30

Very ugly but I need it this way for Excel.
How can I do that?

It really depends on what your data really
looks like (and what you really want)...

for example, using your data (if table.name="yurtable")

TRANSFORM First(t.Costs)
SELECT
t.DRG
FROM
yurtable AS t
GROUP BY
t.DRG
PIVOT "Costs_" & t.Patient;

above crosstab would produce


DRG Costs_a Costs_b Costs_c
============================
A 10 20 15
B 30

My guess is that your data and wanted-results
are more complicated?

good luck,

gary
 
Back
Top