Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    5

    Question Unanswered: Problem to create a query

    Hi,

    I'm new user here and I've a problem with Access 2003.

    I want to create a query wich display the sales of product on this report :

    | PRODUCT | FEBRUARY 2005 | FEBRUARY 2004 | JANUARY TO FEBRUARY 2005 | JANUARY TO FEBRUARY 2005 |

    My table contains this informations :

    PRODUCTS
    DATE
    SALES

    How do I proceed to create this query?

    I don't find it !

    Thanks by advance.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select PRODUCT 
         , sum(iif(DATE between #2005-02-01#
                            and #2005-02-28#
                  ,SALES,0)) as [FEBRUARY 2005]
         , sum(iif(DATE between #2004-02-01#
                            and #2004-02-29#
                  ,SALES,0)) as [FEBRUARY 2004]
         , sum(iif(DATE between #2005-01-01#
                            and #2005-02-28#
                  ,SALES,0)) as [JANUARY TO FEBRUARY 2005]
         , sum(iif(DATE between #2004-01-01#
                            and #2004-02-29#
                  ,SALES,0)) as [JANUARY TO FEBRUARY 2005]
      from daTable
    group
        by PRODUCT
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2005
    Posts
    5
    Very, very thanks.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you're welcome

    did you like how the last column shows the right data but the column name is wrong? that's because it was also wrong in your example, eh

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2005
    Posts
    5
    Yes, my example is wrong!

    I copy this example of my database with the right datas.

Posting Permissions

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