Pivot Table, Consolidating Columns

  • Thread starter Thread starter Melanie
  • Start date Start date
M

Melanie

Hi,

I have some Pivot tables which get their data from an external
database, the table brings back 4 columns 2 fat results and 2 Solid
results

No.Fat-Average Fat-Average-Retest T.S.-Average T.S.-Average-Retest
1 5.125 22.665
2 5.02 22.555
3 5.05 23.37
4 5.175 22.7

What I want to do is only have one column for each result (one for
fat, one for solids) I can do this by creating a seperate column and
having an If statement with the final result in it, but I wondered if
there was a better way of consolidating the two columns into one?
Especially as for some of the tables there can be up to 8 columns with
only one having a result in it. Is there a way of doing this in the
SQL statement or am I stuck with huge if statements that change as my
columns change?
Any help would be much appreciated

Melanie
 
(e-mail address removed) (Melanie) wrote ...
I have some Pivot tables which get their data from an external
database, the table brings back 4 columns 2 fat results and 2 Solid
results

No.Fat-Average Fat-Average-Retest T.S.-Average T.S.-Average-Retest
1 5.125 22.665
2 5.02 22.555
3 5.05 23.37
4 5.175 22.7

What I want to do is only have one column for each result (one for
fat, one for solids)

You may be able to achieve the desired result with the UNION keyword e.g.

SELECT
[Fat-Average] AS Fat,
[T.S.-Average] AS Solid
FROM Table1
UNION
SELECT
[Fat-Average-Retest] AS Fat,
[T.S.-Average-Retest] AS Solid
FROM Table2
;

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top