-1

我想按年获得每列的总和。而是显示同一年的几个单独的行。

spark.sql("""
SELECT YEAR(date) AS year, 
useful, funny, cool
FROM reviews_without_text_table
ORDER by year ASC;
""").show(truncate=False)

[在此处输入图片描述][1]

请在此处查看附件:[1]:https ://i.stack.imgur.com/nYIrA.png

4

1 回答 1

0

用这个

spark.sql("""
SELECT YEAR(date) AS year, 
sum(useful) useful,sum(funny) funny,sum(cool) cool
FROM reviews_without_text_table
GROUP BY YEAR(date)
ORDER by year ASC;
""").show(truncate=False)
于 2022-02-26T03:48:28.820 回答