Skip to content

Tag: snowflake-cloud-data-platform

Parse JSON like VARCHAR Column in Snowflake

I have a VARCHAR column called TAG within a SQL database with the data looking like the example below. Example: Since it is not a JSON column, I am having difficulty parsing through the column to get the postScore value. I have tried to convert this from a VARCHAR to Variant datatype so that I can do somethin…

Unable to convert string to Timestamp

I’m trying to convert a sample 12 hour date with AM/PM into a timestamp, however, Snowflake is throwing an error that it’s not parsable: SELECT TO_TIMESTAMP(‘7/16/2021 4:52:25 AM’, ‘MM/dd/yyyy HH12:mm:ss AM’) The error message returned: Can’t parse ‘7/16/2021 4:…

Using where clause within a partition

I have huge pageview level table, where each session has multiple pageviews. Session -> Pageviews – 1 : M From the pageviews table, I need to consolidate the data into one row per session with meta data like FirstPageview, LastPageview, #ofvisitstoLogin Firstpageview is defined as the very first page…

Case statement with division

I have case statement below as but am getting error on syntax error, is there proper way to divide in case statement? thanks Answer You need to add quotes to the desired column name (if it’s not going to follow traditional naming rules. Change: To: Btw, the exact syntax error you got was Syntax error: u…