• MYSQL语句5


    1.COUNT函数,DISTINCT是不同值。

    %%sql 
    SELECT COUNT(DISTINCT Dog_Guid)
    FROM complete_tests 
    WHERE created_at > '2014-03-01'

    2. SUM 函数

    %%sql 
    SELECT SUM(ISNULL(exclude))
    FROM dogs

    3. AVG, MIN, MAX函数

    %%sql 
    SELECT test_name,
    AVG(rating) AS "AVG_Rating",
    MIN(rating) AS "MIN_Rating",
    MAX(rating) AS "MAX_Rating"
    FROM reviews 
    WHERE test_name="Memory versus Pointing"

    4.统计时间差 TIMESTAMPDIFF函数

    %%sql
    SELECT AVG(TIMESTAMPDIFF(MINUTE, start_time, end_time)) AS "AVG_time"
    FROM exam_answers
    WHERE test_name = "Treat Warm-Up"
    %%sql 
    SELECT *
    FROM exam_answers
    WHERE TIMESTAMPDIFF(MINUTE, start_time, end_time) < 0
    The Safest Way to Get what you Want is to Try and Deserve What you Want.
  • 相关阅读:
    37.js----浅谈js原型的理解
    iOS
    iOS
    iOS
    python3
    ios
    iOS
    python3
    python3
    iOS
  • 原文地址:https://www.cnblogs.com/Shinered/p/9588096.html
Copyright © 2020-2023  润新知