我对 SQL 相当陌生,但相信我在发布此内容之前已经寻求帮助。
我有一个查询,它返回分配给工作的人员列表,这些工作也有不同的长度,分配给这些工作的人工作的长度也不同。
我想要做的是转换什么是类似记录的列表,唯一的变量变化是日期,以及如何旋转这些数据,以便日期成为列标题,行表示 BOOL 是/否。
这是我目前正在取回的数据。JSON编码
{"results":[{"role":"Vision Supervisor","familyname":"Unsworth","givenname":"Simon","skill":"10","level":"Telegenic Staff","id":"664","date":"2013-03-27"},{"role":"Vision Supervisor","familyname":"Unsworth","givenname":"Simon","skill":"10","level":"Telegenic Staff","id":"664","date":"2013-03-26"},{"role":"Vision Supervisor","familyname":"Unsworth","givenname":"Simon","skill":"10","level":"Telegenic Staff","id":"664","date":"2013-03-25"},{"role":"Vision Supervisor","familyname":"Unsworth","givenname":"Simon","skill":"10","level":"Telegenic Staff","id":"664","date":"2013-03-24"}]}
我想回来的是:
{"results":[{"role":"Vision Supervisor","familyname":"Unsworth","givenname":"Simon","skill":"10","level":"Telegenic Staff","id":"664","2013-03-27":"YES","2013-03-26":"YES","2013-03-25":"YES","2013-03-24":"YES"}]}
我确定这是某种 PIVOT 查询,但我无法让它工作。
谢谢