• SQL with pivot expression (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » SQL with pivot expression (Access 2000)

    Author
    Topic
    #365748

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #565278

      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).

    Viewing 0 reply threads
    Reply To: SQL with pivot expression (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: