Lets take a very simple table
Department | Staff Name
---------------------|---------------
Web - Electronics | Matthew
Store - Electronics | Mark
Web - Home | Luke
Store - Home | John
Store - Home | Paul
Store - Home | Simon
Web - Electronics | Peter
I need to work out some SQL to return the following:
Deparment | Web | Store
-------------|------|---------
Electronics | 2 | 1
Home | 1 | 3
So I need to do a count of web and store for each department. Is it possible to do something like this in SQL?
In C# I would loop through the results. I would split the deparment into two strings on the -. I would add an entry in a dictonary so the deparment name is the key. For the entry I would have a small object with a field of Web and Store. I would then increment the value by one if the entry is stor or web.
After this I would then loop throgu hmy dictiaonry to output the result by priting the dictionary key then printing the count for web and store.
I am not even sure where to begin trying to do this in just SQL...