MYSQL语句5

mac2022-06-30  126

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

 

转载于:https://www.cnblogs.com/Shinered/p/9588096.html

最新回复(0)