我有这样一张桌子:
id | timestamp | type
-----------------------
1 2010-11-20 A
2 2010-11-20 A
3 2010-11-20 B
4 2010-11-21 A
5 2010-11-21 C
6 2010-11-27 B
Run Code Online (Sandbox Code Playgroud)
我需要计算每种类型的行数,按工作日分组; 像这样:
weekday | A | B | C
--------------------------
5 2 2 0 -- the B column equals 2 because nov 20 and nov 27 are saturday
6 1 0 1
Run Code Online (Sandbox Code Playgroud)
对此最简单的解决方案是什么?
我不介意使用视图,变量,子查询等.