Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
divan
Posting Yak Master
153 Posts |
Posted - 2013-08-23 : 20:24:36
|
I have a table that has two columns POLICY_NUMBER and POLICY_TYPEPOLICY_NUMBER POLICY-TYPE123 1123 1123 1567 2567 2789 1789 1345 1345 1345 1I need to write a script that give me the following resultpolicy_type_count policy_type3 11 2 |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-08-23 : 20:41:39
|
James K responded to your post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=187749with the following query, it should give you what you want:[CODE]SELECT COUNT(DISTINCT policy_number) AS policy_type_count, [policy-type]FROM YourTableGROUP BY [policy-type][/CODE] |
 |
|
divan
Posting Yak Master
153 Posts |
Posted - 2013-08-23 : 20:53:15
|
But I do not see the query |
 |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-08-23 : 21:47:34
|
quote: Originally posted by divan But I do not see the query
Do you see this one:[CODE]SELECT COUNT(DISTINCT policy_number) AS policy_type_count, [policy-type]FROM YourTableGROUP BY [policy-type] [/CODE] |
 |
|
|
|
|