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?
You probably just want the
countfunction:The MSDN reference for group by describes it better than I could: