I need to select some info from the DB, per day and per team. I want to see how many items were bought per day, for each team. For example, if there were 6 items bought in 2012-11-21, I want my results to show: team 1 bought 3 items, team 2 – 2 items and the last team 1 item. I can get the info for one team, using this:
select count(CONVERT(date, getdate())) as Team1
from items
where team = 1
group by CONVERT(date, getdate())
But I am not sure how can I get the info I need, for all the teams.
EDIT
I need the results to be something like this:
Date |Team1 | Team2 | Team3
2012-11-21|2 items | 3 items | 0 items
And my table structure is something like this: Date, Product, Price, Team.
What you need here, is
PIVOTyour table like so: