+ Reply to Thread
Results 1 to 4 of 4

Pivot table using External data

  1. #1
    nc
    Guest

    Pivot table using External data

    Hi

    I am generating a pivot table using the following query

    SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
    FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
    REG$'` `'1100 REG$'`
    UNION
    SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
    FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
    REG$'` `'1157 REG$'`
    UNION
    SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
    FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
    REG$'` `'1165 REG$'`

    The problem I am having is that I am getting a difference in the total
    amount when the same query is generated individually for 1100 REG, 1157 REG
    and 1165REG and aggregated. Why?


  2. #2
    Debra Dalgleish
    Guest

    Re: Pivot table using External data

    Try UNION ALL instead of UNION.

    nc wrote:
    > Hi
    >
    > I am generating a pivot table using the following query
    >
    > SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
    > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
    > REG$'` `'1100 REG$'`
    > UNION
    > SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
    > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
    > REG$'` `'1157 REG$'`
    > UNION
    > SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
    > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
    > REG$'` `'1165 REG$'`
    >
    > The problem I am having is that I am getting a difference in the total
    > amount when the same query is generated individually for 1100 REG, 1157 REG
    > and 1165REG and aggregated. Why?
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


  3. #3
    nc
    Guest

    Re: Pivot table using External data

    Hi Debra

    Thanks, it works. What is the differene between the two?

    "Debra Dalgleish" wrote:

    > Try UNION ALL instead of UNION.
    >
    > nc wrote:
    > > Hi
    > >
    > > I am generating a pivot table using the following query
    > >
    > > SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
    > > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
    > > REG$'` `'1100 REG$'`
    > > UNION
    > > SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
    > > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
    > > REG$'` `'1157 REG$'`
    > > UNION
    > > SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
    > > FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
    > > REG$'` `'1165 REG$'`
    > >
    > > The problem I am having is that I am getting a difference in the total
    > > amount when the same query is generated individually for 1100 REG, 1157 REG
    > > and 1165REG and aggregated. Why?
    > >

    >
    >
    > --
    > Debra Dalgleish
    > Excel FAQ, Tips & Book List
    > http://www.contextures.com/tiptech.html
    >
    >


  4. #4
    Debra Dalgleish
    Guest

    Re: Pivot table using External data

    By default, UNION excludes duplicate records. UNION ALL retains the
    duplicate values.

    nc wrote:
    > Hi Debra
    >
    > Thanks, it works. What is the differene between the two?
    >
    > "Debra Dalgleish" wrote:
    >
    >
    >>Try UNION ALL instead of UNION.
    >>
    >>nc wrote:
    >>
    >>>Hi
    >>>
    >>>I am generating a pivot table using the following query
    >>>
    >>>SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
    >>>FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
    >>>REG$'` `'1100 REG$'`
    >>>UNION
    >>>SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
    >>>FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
    >>>REG$'` `'1157 REG$'`
    >>>UNION
    >>>SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
    >>>FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
    >>>REG$'` `'1165 REG$'`
    >>>
    >>>The problem I am having is that I am getting a difference in the total
    >>>amount when the same query is generated individually for 1100 REG, 1157 REG
    >>>and 1165REG and aggregated. Why?
    >>>

    >>
    >>
    >>--
    >>Debra Dalgleish
    >>Excel FAQ, Tips & Book List
    >>http://www.contextures.com/tiptech.html
    >>
    >>

    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1