Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL with pivot expression (Access 2000)

    SQL with Pivot expression

    The following expression is a part of my sql clause and does not work:

    dim strPivot as String
    strPivot = "PIVOT Qtr & DatePart(q,[InvoiceDate],1,0) In (Qtr 1,Qtr 2,Qtr 3,Qtr 4)"

    When i put this expression in an sql clause, i receive an error mssing operator.
    Without the strPivot expression, my SQL works.Do i have some errors in my expression?

  2. #2
    New Lounger
    Join Date
    Jan 2001
    Location
    Vermont
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL with pivot expression (Access 2000)

    I think you need some quotes. I tried the following and it worked nicely:

    TRANSFORM Count(1) AS CountOfADate
    SELECT Count(1) AS [Total Of ADate]
    FROM RandomDates
    GROUP BY 1
    PIVOT "Qtr" & DatePart("q",[Adate]) In ("Qtr1","Qtr2","Qtr3","Qtr4");

    (where RandomDates is a table containing a field ADate full of random dates).

Posting Permissions

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