I suggest you to install Group Stats plugin. Here is a quick tutorial:
- Search for the Group Stats icon
- Select the layer in which you have the Codes
- Select the attribute (in your case Code)
- Click on Calculate
The Count will appear. If you go to preferencepreferences you should be able to select only Count avoiding the other parameters to be displaydisplayed (this is not my case...). Remember before click Save button you have to select the featuresfields you want to add to your .csv: hold on Shift for do that. Here is a more advanced tutorial written by Anita Graser.