Warm tip: This article is reproduced from serverfault.com, please click

Combining related records with multiple True/False values into a single record

发布于 2020-11-30 16:59:17

I'm trying to combine class meeting data for a large set of classes, based upon multi-column logic. For each class nbr (first column) I can have multiple y/n entries corresponding to whether the class meets that day or not. I need to:

Have a single entry for each ClassNbr/DayOfWeek/MtgStart/MtgEnd combination .

I've used Browne's ConcatRelated() function to great effect to get part of the way there, but I'm stumped with how to get the y/n columns to line up correctly, and I'm stumped on where to go next. This is part of a larger Access 2016 database and needs to stay in it. I'm comfortable using VBA if necessary.

Basic Problem:

enter image description here

Current vs. Expected Real World Result:

enter image description here

Questioner
Stefan Malliet
Viewed
0
Gordon Linoff 2020-12-01 01:10:20

You should be able to use aggregation functions:

select col1, min(a) as a, min(b) as b, min(c) as c
from t
group by col1;

Because MS Access stores "Y" as -1 and "N" as 0, MIN() is equivalent to OR.