I have a table with 300k records containing the following data (sample)
The first 3 characters of the code field are all records belonging to a group, for example 572 or 589 or 802.
I want to create a query that summarizes if records exists for each group in a specific year and month
Result should be
alternative I tried to get a result with the months in a string variable using DLIST, but that function does not have a grouping option. I already tried some other queries, but every time it is not quite what I had in mind.
For example
But this displays a line for each month. It should be something with grouping in a group, but I’m stuck. Now I'm wondering if this is possible within a query. Does anyone has an idea?
Art.
Code:
Id p_year p_month code
59901 2024 02 820996
59902 2024 01 5721012
59903 2024 02 826193
59904 2024 01 820139
59905 2024 02 821012
59906 2024 01 821032
59907 2024 01 821173
59908 2024 02 5741237
59909 2024 01 821065
59910 2024 01 826193
59911 2024 02 820708
59912 2024 02 826217
59913 2024 01 821086
The first 3 characters of the code field are all records belonging to a group, for example 572 or 589 or 802.
I want to create a query that summarizes if records exists for each group in a specific year and month
Result should be
Code:
Group Year JAN FEB MAR etc
082 2023 X X X
572 2024 X X
alternative I tried to get a result with the months in a string variable using DLIST, but that function does not have a grouping option. I already tried some other queries, but every time it is not quite what I had in mind.
For example
Code:
SELECT Left(Format([code],"0000000"),3) AS code, a.p_year AS [year], a.p_month AS JAN, a.p_month AS FEB
FROM be_performance AS a
GROUP BY Left(Format([code],"0000000"),3), a.p_year, a.p_month, a.p_month
HAVING (((a.p_month)=1)) OR (((a.p_month)=2));
But this displays a line for each month. It should be something with grouping in a group, but I’m stuck. Now I'm wondering if this is possible within a query. Does anyone has an idea?
Art.