This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1.1.1 登録ユーザー数, アクティブユーザー数 -- | |
td query -w -d book_crossing_dataset " | |
SELECT t1.cnt AS all_users, t2.cnt AS active_users, ROUND(t2.cnt/t1.cnt*100) AS active_rate | |
FROM | |
( | |
SELECT COUNT(distinct user_id) as cnt, 1 AS one | |
FROM users | |
) t1 | |
JOIN | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WHERE TD_INTERVAL(time, '-10y/-1M', 'JST') /* 1ヶ月前より過去 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC']) | |
-- (例)2013年のデータを取得 | |
SELECT ... WHERE TD_TIME_RANGE(time, "2013-01-01 JST", "2014-01-01 JST") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# install: http://morgangoose.com/blog/2011/01/06/using-the-parallel-branch-of-fabric/ | |
# document: http://docs.fabfile.org/en/1.2.0/index.html | |
# | |
import os | |
from fabric.api import * | |
from fabric.decorators import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TD_DATE_TRUNC('day',time,'JST') AS access_day |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* TD_SCHEDULED_TIME() = '2018-11-23 11:11:00' */ | |
/* | |
SELECT target_month, segment, COUNT(1) AS cnt | |
FROM | |
( | |
*/ | |
SELECT target_month, | |
CASE | |
WHEN 50<=ratio_freq_sleeping OR 50<=ratio_pv_sleeping THEN 'sleeping' | |
WHEN 50<=ratio_freq_morning OR 50<=ratio_pv_morning THEN 'morning' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TD_TIME_FORMAT(time,'u','JST') # 1(月曜日) 〜 7(日曜日) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 基準日 = '2018-11-23 11:11:00' | |
[2018-11-22 00:00:00, 2018-11-23 00:00:00) # 日次 | |
[2018-11-12 00:00:00, 2018-11-19 00:00:00) # 週次 | |
[2018-10-01 00:00:00, 2018-11-01 00:00:00) # 月次 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 3.1.1 出版年別分布 -- | |
td query -w -d book_crossing_dataset " | |
SELECT year, cnt | |
FROM | |
( | |
SELECT 1975 AS year, COUNT(year_of_publication) AS cnt | |
FROM books | |
WHERE year_of_publication < 1970 | |
UNION ALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM table1 | |
WHERE | |
col1 < 100 | |
OR col2 is TRUE | |
AND TD_TIME_RANGE(time, '2015-11-01') | |
NewerOlder