英文:
Add up the duplicate values
问题
我想知道每小时的推文总数,但它给我重复的数据。
想要的结果如下:
| 每小时推文数 | 总推文数 |
| ------------ | -------------- |
| 11 | 31 |
| 12 | 27 |
英文:
I want to know the total number of tweets by the hour but it gives me duplicates.
SELECT DISTINCT datepart(hh,tweet_created) AS hours_tweeted, COUNT(tweet_text) AS total_tweets
FROM [New_years_resolutions_2020]
GROUP BY tweet_created
ORDER BY total_tweets DESC;
hours_tweeted | total_tweets |
---|---|
11 | 16 |
11 | 15 |
12 | 14 |
12 | 13 |
I want something like this
hours_tweeted | total_tweets |
---|---|
11 | 31 |
12 | 27 |
答案1
得分: 0
你可以尝试以下查询以获得所需结果
选择 datepart(hh, tweet_created) 作为 hours_tweeted, COUNT(DISTINCT tweet_text) 作为 total_tweets
从 [新年愿望_2020]
按 datepart(hh, tweet_created) 分组
按 total_tweets 降序排序;
英文:
You can try this query to get the desired result
SELECT datepart(hh, tweet_created) AS hours_tweeted, COUNT(DISTINCT tweet_text) AS total_tweets
FROM [New_years_resolutions_2020]
GROUP BY datepart(hh, tweet_created)
ORDER BY total_tweets DESC;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论