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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:06:07+00:00 2026-06-10T12:06:07+00:00

Here is what I have: A MSSQL DB and table with lets say 200

  • 0

Here is what I have:

A MSSQL DB and table with lets say 200 rows

Python 2.7 and pyodbc

There is a column, we will call type, and in the rows under it contain an unknown quantity of unique values. For instance, right now there is the possibility of a,b,c,d,e and f for the values but in the future, a may go away or we might add g.

Therefore I do not believe I can have a predefined set of variables or a dictionary of some sorts to reference.

My goal is to have python/sql look at the table, determine how many unique items there are and then count up the totals of each unique item, giving me an output like: there are 50 a’s and 23 b’s and 5 c’s

Is there some function out there that accomplishes this or is there something in SQL that would do this for me? Would I have to determine the amount of unique items and then run sql statements for each item?

  • 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-06-10T12:06:08+00:00Added an answer on June 10, 2026 at 12:06 pm

    You probably just want the count function:

    COUNT

    Returns the number of items in a group.

    select count(*), type from that_one_table group by type
    

    The MSDN reference for group by describes it better than I could:

    GROUP BY

    Groups a selected set of rows into a set of summary rows by the values of one or more columns or expressions in SQL Server 2012. One row is returned for each group. Aggregate functions in the SELECT clause list provide information about each group instead of individual rows.

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

Sidebar

Related Questions

Let's say we have a table with columns DAY and NUMERO. There can be
Let's say I have records in a MySQL table that have a unix timestamp
Let's say I have a MySQL database with 3 tables: table 1: Persons, with
Can someone please help me with MySQL Trigger Lets say I have two Tables
I am using php and mysql. i have a question, lets say, I have
I have an interesting problem here. I have a MySql database table that has
Let's say I have a legacy MySQL table called server with fields serverid:integer and
There is a table with the following stucture: Here are the data in this
Updated Hello all, MySQL here. Let's say we have 3 tables. TableA , TableB
I have a simple question about MySQL and PHP here. Let's say I have

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.