sql server - Make a query which adds a column to display the number of repetitions of every items in a table -


i need sql server command, should add column in table consisting of number of times each element in specific column repeated. , want table display no repetition of item beeing counted . table.

medication_id   prescription_id             dossage  12                    1013                 blablabla  17                    1013                 blablabla  15                    1013                 blablabla  12                    1013                 blablabla  12                    1013                 blablabla  12                    1013                 blablabla  12                    1014                 blablabla  12                    1014                 blablabla  12                    1014                 blablabla  15                    1013                 blablabla  15                    1013                 blablabla  17                    1015                 blablabla  12                    1016                 blablabla 

i want generate this:

  medicatition id | numberofrepetitions   12                     8   15                     3   17                     2 

this simple grouping:

select medication_id, count(*) numberofrepetitions tablename group medication_id 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -