Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 192385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:25:18+00:00 2026-05-11T16:25:18+00:00

I have a table that contains, among other things, about 30 columns of boolean

  • 0

I have a table that contains, among other things, about 30 columns of boolean flags that denote particular attributes. I’d like to return them, sorted by frequency, as a recordset along with their column names, like so:

Attribute    Count
attrib9      43
attrib13     27 
attrib19     21
etc.

My efforts thus far can achieve something similar, but I can only get the attributes in columns using conditional SUMs, like this:

SELECT SUM(IIF(a.attribIndex=-1,1,0)), SUM(IIF(a.attribWorkflow =-1,1,0))...

Plus, the query is already getting a bit unwieldy with all 30 SUM/IIFs and won’t handle any changes in the number of attributes without manual intervention.

The first six characters of the attribute columns are the same (attrib) and unique in the table, is it possible to use wildcards in column names to pick up all the applicable columns?

Also, can I pivot the results to give me a sorted two-column recordset?

I’m using Access 2003 and the query will eventually be via ADODB from Excel.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:25:18+00:00Added an answer on May 11, 2026 at 4:25 pm

    This depends on whether or not you have the attribute names anywhere in data. If you do, then birdlips’ answer will do the trick. However, if the names are only column names, you’ve got a bit more work to do–and I’m afriad you can’t do it with simple SQL.

    No, you can’t use wildcards to column names in SQL. You’ll need procedural code to do this (i.e., a VB Module in Access–you could do it within a Stored Procedure if you were on SQL Server). Use this code build the SQL code.

    It won’t be pretty. I think you’ll need to do it one attribute at a time: select a string whose value is that attribute name and the count-where-True, then either A) run that and store the result in a new row in a scratch table, or B) append all those selects together with “Union” between them before running the batch.

    My Access VB is more than a bit rusty, so I don’t trust myself to give you anything like executable code….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that contains among other things partial postal codes. I'm
I have a function that returns a table. The returned table contains (among other
I have a table that contains procedure codes among other data (let's call it
I have an HTML table whose cells contain, among other things, spans, like this:
I have a view that - among other things - contains a list of
I have a web application which among other things contains a table of items
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table that contains all the data about users . Users can
I have a table that contains common entries in two columns. For Example: Column1
I have a view which contains (among other columns) a header name, and an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.