Results 1 to 7 of 7
  1. #1
    mbar is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    12

    sql and/or pivot?


    I'm not sure how to explain (and therefore search) this so forgive me if this has already been answered.

    Here is my current table (I've changed the field names to make it easier):

    Date Deposit
    4-5-11 $1000
    4-5-11 $2000
    4-5-11 $500
    4-6-11 $200
    4-6-11 $100

    how can I modify the results to show:
    Date shift1 shift2 shift3
    4-5-11 $1000 $2000 $500
    4-6-11 $200 $100 $0 or null

    I think I'm missing an SQL command?

    Any help would be greatly appreciated

    thanks a lot
    I

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Code:
    TRANSFORM table.deposit
    
    SELECT table.date
    
    FROM table
    
    GROUP BY table.date
    
    PIVOT table.deposit

  3. #3
    mbar is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    12
    thanks for the reply- this almost worked...

    how do I set the field names to "shift1", "shift2", ect..?

    basically, its output is that of a crosstab and the current field names are that of the record. in other words, if the record is $1000, the field name is "1000". unless another record is $1000, then the field is blank for other dates.

    thanks

  4. #4
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    If you have a field that tracks shift, you'll want to include it in your query.

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by mbar View Post
    the current field names are that of the record. in other words, if the record is $1000, the field name is "1000". unless another record is $1000, then the field is blank for other dates.
    I understand that. I've not done many crosstab queries in my lifetime. Only financials. I did not know anything about this. I simply used the crosstab wizard and modified the sql.

    I don't know how to use aliases in the names. I don't believe you can, but you can experiment on your own. If it turns out you can't, you can always loop the table and change them that way.

  6. #6
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Your original data needs some way to identify the shift....something like below. Then you can make the shift field your column header and the Deposit the value in the crosstab.

    Date Deposit shift
    4-5-11 $1000 Shift1
    4-5-11 $2000 Shift2
    4-5-11 $500 Shift3
    4-6-11 $200 Shift1
    4-6-11 $100 Shift1

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    mbar,

    I have unsubscribed to your thread. Letting you know. I'm not interested in confusing posters with more than one road to follow. good luck to ya.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pivot Chart help.
    By lorenambrose in forum Access
    Replies: 8
    Last Post: 02-16-2011, 12:02 PM
  2. Pivot Charts
    By Vikki in forum Access
    Replies: 3
    Last Post: 02-08-2010, 11:14 AM
  3. Creating a Pivot Chart....
    By spcalan in forum Access
    Replies: 0
    Last Post: 01-08-2009, 03:28 PM
  4. Pivot Charts
    By Ruby in forum Access
    Replies: 0
    Last Post: 11-16-2007, 05:56 PM
  5. pivot table totals
    By brian12pme in forum Forms
    Replies: 0
    Last Post: 12-07-2005, 03:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums