Forked from seanickle/AWS Athena timestamp select query .md
Created
January 4, 2023 14:36
-
-
Save Kouni/311eb2fa3cf77172ad7c8649367a7b28 to your computer and use it in GitHub Desktop.
Revisions
-
seanickle revised this gist
Sep 11, 2018 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ #### length can also be checked on a varchar field ``` SELECT * FROM blah WHERE length(blah_field) = 10 ``` #### can treat a string field as a number as well.. ``` SELECT * FROM blah WHERE (cast(blah_numeric_string_field as double)) >= 10 ``` -
seanickle revised this gist
Aug 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ * Here, the Athena table `athena_table` has the columns `timestamp, day, month, year, id` * ```sql select timestamp,month,day,year,id from athena_table WHERE month = 8 and day = 15 -
seanickle created this gist
Aug 22, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #### Doing a SELECT on a specific timestamp range * Here, the Athena table `athena_table` has the columns `timestamp, day, month, year, id` * ```sql select timestamp,day,month,year,id from athena_table WHERE month = 8 and day = 15 AND (CAST(timestamp as varchar) BETWEEN '2018-08-15 22:00:00' AND '2018-08-15 22:10:00') ORDER BY timestamp DESC ``` x|timestamp|month|day|year|id --|--|--|--|--|-- 1 |2018-08-15 22:03:25.296 |15 |8| 2018| 12344 2 |2018-08-15 22:02:59.266 |15 |8| 2018| 12345