我有一个查询,该查询从某些时间数据返回数据透视表:
SELECT *
FROM TIME
WHERE CONVERT(DATETIME,DATE,101) >= '2019-02-24' AND CONVERT(DATETIME,DATE,101) <= '2019-03-02'),
Pivoted AS (
SELECT *
FROM QueryTable
PIVOT (max (DURATION) for DATE in ([02/24/2019],[02/25/2019],[02/26/2019],[02/27/2019],[02/28/2019],[03/01/2019],[03/02/2019])) as pvt
), ProcessTable As (
SELECT
EmpID, JOB, ITEM, PITEM, PROJ, [02/24/2019],[02/25/2019],[02/26/2019],[02/27/2019],[02/28/2019],[03/01/2019],[03/02/2019], NOTE
FROM Pivoted
WHERE EmpID = '171'
GROUP BY EmpID, JOB, ITEM, PITEM, PROJ, [02/24/2019],[02/25/2019],[02/26/2019],[02/27/2019],[02/28/2019],[03/01/2019],[03/02/2019], NOTE
)
SELECT * FROM ProcessTable
日期和EmpID由Web应用程序动态填充,这些值只是占位符。该查询的当前结果是:
我想再次对表进行分组以获得最终结果,如下所示:
这可以实现吗?
答案 0 :(得分:0)
您可以轻松地将此表示为条件聚合:
keywords = ["hello", "okay"]
subreddits = ["test", "bottest"]
for comment in r.subreddit(any(subreddits)).comments(limit=100):
if any(keywords) in comment.body and comment.id not in comments_replied_to
and comment.author != r.user.me():
我不确定这是否适合您的网络应用。