我需要在查询中包含空值的帮助。我们说我有这张桌子:
table1:
| in/out | year | name |
| in | 2011-12| jim
| in | 2011-12| tim
| in | 2012-13| toby
| out | 2011-12| ron
| out |2012-13 | jim
| out |2012-13 | joel
我创建了这个转换语句:
Transform Count(*)
SELECT [in/out] FROM table1 WHERE name = "jim" GROUP BY [in/out]
PIVOT year IN("2011-12", "2012-13");
要获得此表:
|in/out| 2011-12 | 2012-13
| in | 1 | 1
我想要包含所有输入/输出值,即使它们是空的,所以对于这个例子,我希望表格看起来像这样:
|in/out| 2011-12 | 2012-13
| in | 1 | 1
| out | |
非常感谢任何帮助。谢谢!