Create a List of Dates in Access Query

前端 未结 2 1883
礼貌的吻别
礼貌的吻别 2020-12-17 03:39

I have a MakeTable query in Access that I am working on. I want to make it so that one of the fields in the table being created will be a list of dates in chronological orde

2条回答
  •  时光说笑
    2020-12-17 04:25

    I'd create a table with three fields:

    [Snapshot Date]   date
    [CountA]          number
    [CountB]          number
    

    Fill the Snapshot Date column in with a wide range of dates (yours inclusive) -- you can do this through code or just cut/paste from a spreadsheet.

    Then save a crosstab query similar to this:

    TRANSFORM Avg([All Dates].[CountB]) AS DeleteMe
    SELECT [All Dates].[CountA]
    FROM [All Dates]
    WHERE [All Dates].[Snapshot Date] Between #1/2/2015# and #11/30/2015#
    GROUP BY [All Dates].[CountA]
    PIVOT [All Dates].[Snapshot Date];
    

    (once you save this query, you should be able to switch to design view and see what the designer looks like)

    Assuming the crosstab query above was named All Dates Crosstab, you could:

    select *
    into [My New Table]
    from [All Dates Crosstab]
    

提交回复
热议问题