You are viewing limited content. For full access, please sign in.

Question

Question

Value Count from SQL Table Query

asked on February 2, 2022

Trying build a workflow that will query a column in a SQL table that contains states abbreviations (about 3000 records) that will count different values in that column.  I need to keep a running count of each state in the list, then take action when the count reaches 5 for any state. 

I'm trying to avoid addressing each state independently.

Any suggestions would be appreciated!

0 0

Answer

SELECTED ANSWER
replied on February 2, 2022

SELECT stateCode, COUNT(*)

  FROM table

 GROUP BY stateCode

HAVING COUNT(*) >=5;

(that way you don't have to figure out which values you care about, you only get the ones that need action)

0 0

Replies

replied on February 2, 2022

SELECT stateCode, COUNT(*)

  FROM table

 GROUP BY stateCode;

1 0
SELECTED ANSWER
replied on February 2, 2022

SELECT stateCode, COUNT(*)

  FROM table

 GROUP BY stateCode

HAVING COUNT(*) >=5;

(that way you don't have to figure out which values you care about, you only get the ones that need action)

0 0
replied on February 2, 2022

:)

0 0
replied on February 3, 2022

Thanks to you both.  This was perfect!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.