Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What is going on with this article?
@rysk92

Athena の datetime 型のある Schema にて 時間・分・秒単位での行数を知る方法

More than 3 years have passed since last update.

datetime 型あり

SELECT format_datetime( DATETIME_COLUMN_NAME,'YYYY-MM-dd HH'), count(*)
FROM "ATHENA_DATABASE"."ATHENA_TABLE"
WHERE year=2018
        AND month=3
        AND (day=29
        OR day =30)
        GROUP BY format_datetime(DATETIME_COLUMN_NAME,'YYYY-MM-dd HH')
        ORDER BY format_datetime(DATETIME_COLUMN_NAME,'YYYY-MM-dd HH') ASC

format_datetime とかつかって datetime 型に変換するなら

SELECT format_datetime(date_parse(DATE_STR_COLUMN_NAME,'%d/%b/%Y:%H:%i:%s +0000'),'YYYY-MM-dd HH'), count(*)
FROM "ATHENA_DATABASE"."ATHENA_TABLE"
WHERE year=2018
        AND month=3
        AND (day=29
        OR day =30)
        GROUP BY format_datetime(date_parse(DATE_STR_COLUMN_NAME,'%d/%b/%Y:%H:%i:%s +0000'),'YYYY-MM-dd HH')
        ORDER BY format_datetime(date_parse(DATE_STR_COLUMN_NAME,'%d/%b/%Y:%H:%i:%s +0000'),'YYYY-MM-dd HH') ASC"

YYYY-MM-dd HH -> YYYY-MM-dd HH-mm

YYYY-MM-dd HH -> YYYY-MM-dd HH-mm-ss

2
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
rysk92
sprocket
"Sprocket(スプロケット)は、Webサイトにおけるコンバージョン(購入・入会・資料請求・問合せ等)を増やしたい企業様向けに、自社開発のWeb接客ツールの導入及びコンバージョン改善コンサルティングを行っている会社です。 "

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
2
Help us understand the problem. What is going on with this article?