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 7278477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:52:47+00:00 2026-05-28T22:52:47+00:00

Say I have a table A and it has 5 columns (Column1, Column2.. Column5),

  • 0

Say I have a table A and it has 5 columns (Column1, Column2.. Column5), the values in each column is one char size and stored only
as alphabetic as follows


    ID Column1 Column2 Column3 Column4 Column5
    1   A        C       D        A      B
    2   A        D       A        B      A
    3   B        K       Q        C      Q
    4   A        K       E        E      B
    5   F        K       F        F      S


I need a count of each different value stored in column1 to column5, I want the following information


     Column1 has A's count=3, B's count=1, F's count=1
     Column2 has C's count=1, D's count=1, K's count=3

     and so on


What is the correct way and format to return these values?

Thanks

  • 1 1 Answer
  • 0 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-28T22:52:48+00:00Added an answer on May 28, 2026 at 10:52 pm

    You could try:

    SELECT 'Col1' As 'Col', Column1 as 'Value', COUNT(*) as 'Ct'
    FROM MyTable
    GROUP BY Column1
    UNION ALL
    SELECT 'Col2', Column2, COUNT(*)
    FROM MyTable
    GROUP BY Column2
    ...
    

    You will need to write an additional SELECT to UNION for each column you want to aggregate, but it will return the data you are after.

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

Sidebar

Related Questions

Let's say I have a table Foo . This table has the columns ID
Lets say I have a table in MySQL called articles, that has a column
Lets say I have one table called REVIEWS This table has Reviews that customers
I have a Postgre database that has say 10 columns. The fifth column is
Let's say I have 2 tables. TableA only has one column and looks like
Let's say I have a table that has user_id, date, score, and every user
Let's say I have a Customer table which has a PrimaryContactId field and a
Let's say I have an Order table which has a FirstSalesPersonId field and a
Say if I have a large dataset, the table has well over a million
Which is your preference? Let's say we have a generic Product table that has

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.