troubleshooting Question

count 1s in access 2016

Avatar of PeterBaileyUk
PeterBaileyUk asked on
Microsoft AccessRegular Expressions
6 Comments1 Solution137 ViewsLast Modified:
I have a query that tells me where the data has changed over a period the fields represent the data element

the last column gives me the representation of what changed. I would also like a numerical count so i can sort by number of changes.

so 10000000 =1
      00100111=4


and so on but not sure how to do that, i wonder if maybe regular expressions can do that or maybe a function

SELECT TblUnionCodes.Capcode, Count(QryLongModelDescEvents.CapCode) AS LongModelDesc, Count(QryManfEvents.CapCode) AS Manf, Count(QryNomEvents.CapCode) AS Nom, Count(QrySeatsEvents.CapCode) AS Seats, Count(QryShortModelDescEvents.CapCode) AS ShortModelDesc, Count(QryTransmissionEvents.CapCode) AS Transmission, Count(QryValvesEvents.CapCode) AS Valves, Count(QryWBaseTypeEvents.CapCode) AS WBaseType, IIf(Count([QryLongModelDescEvents].[capcode])>0,"1",0) & IIf(Count([QryManfEvents].[capcode])>0,"1",0) & IIf(Count([QryNomEvents].[capcode])>0,"1",0) & IIf(Count([QrySeatsEvents].[capcode])>0,"1",0) & IIf(Count([QryShortModelDescEvents].[capcode])>0,"1",0) & IIf(Count([QryTransmissionEvents].[capcode])>0,"1",0) & IIf(Count([QryValvesEvents].[capcode])>0,"1",0) & IIf(Count([QryWBaseTypeEvents].[capcode])>0,"1",0) AS ResultString
FROM (((((((TblUnionCodes LEFT JOIN QryLongModelDescEvents ON TblUnionCodes.Capcode = QryLongModelDescEvents.CapCode) LEFT JOIN QryManfEvents ON TblUnionCodes.Capcode = QryManfEvents.CapCode) LEFT JOIN QryNomEvents ON TblUnionCodes.Capcode = QryNomEvents.CapCode) LEFT JOIN QrySeatsEvents ON TblUnionCodes.Capcode = QrySeatsEvents.CapCode) LEFT JOIN QryShortModelDescEvents ON TblUnionCodes.Capcode = QryShortModelDescEvents.CapCode) LEFT JOIN QryTransmissionEvents ON TblUnionCodes.Capcode = QryTransmissionEvents.CapCode) LEFT JOIN QryValvesEvents ON TblUnionCodes.Capcode = QryValvesEvents.CapCode) LEFT JOIN QryWBaseTypeEvents ON TblUnionCodes.Capcode = QryWBaseTypeEvents.CapCode
GROUP BY TblUnionCodes.Capcode
HAVING (((Count(QryLongModelDescEvents.CapCode))>0)) OR (((Count(QryManfEvents.CapCode))>0)) OR (((Count(QryNomEvents.CapCode))>0)) OR (((Count(QrySeatsEvents.CapCode))>0)) OR (((Count(QryShortModelDescEvents.CapCode))>0)) OR (((Count(QryTransmissionEvents.CapCode))>0)) OR (((Count(QryValvesEvents.CapCode))>0)) OR (((Count(QryWBaseTypeEvents.CapCode))>0))
ORDER BY IIf(Count([QryLongModelDescEvents].[capcode])>0,"1",0) & IIf(Count([QryManfEvents].[capcode])>0,"1",0) & IIf(Count([QryNomEvents].[capcode])>0,"1",0) & IIf(Count([QrySeatsEvents].[capcode])>0,"1",0) & IIf(Count([QryShortModelDescEvents].[capcode])>0,"1",0) & IIf(Count([QryTransmissionEvents].[capcode])>0,"1",0) & IIf(Count([QryValvesEvents].[capcode])>0,"1",0) & IIf(Count([QryWBaseTypeEvents].[capcode])>0,"1",0) DESC;

Open in new window

ee.PNG
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004