【问题标题】:Average temperature by day of year with SQLite DDB使用 SQLite DDB 的一年中一天的平均温度
【发布时间】:2020-04-18 16:03:41
【问题描述】:

我正在寻找一个很好的解决方案来从 SQLite 数据库中显示一年中的每一天的平均温度。

在我的数据库中,作为示例,我有一个日期列和一个临时列,用于 5 年来的每一天。

example

我想从我的数据库中获取一年中每一天的平均温度。 我找到了计算一天平均值的请求,但我不知道我怎么能每天都这样做

SELECT avg(min) FROM historique WHERE strftime('%m-%d', date )= "04-01";

你能帮帮我吗?

【问题讨论】:

    标签: sqlite average temperature


    【解决方案1】:

    你必须使用 GROUP BY:

    SELECT strftime('%m-%d', date) day, avg(min) 
    FROM historique 
    GROUP BY day
    

    【讨论】:

    • 哦,太好了!感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-27
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多