Skip to content
Advertisement

Tag: snowflake-cloud-data-platform

issues converting output from a view to json and array in snowflake using SQL

I am new to snowflake and have successfully created a view from a table using sql, but I am having issues creating a view that transforms the whole table into Json and array my view my_view output id town created_date updated_at Services 123 modak 2024-03-29 2024-03-29 [{ “service”: “green”, “period”:{“Type”: “definite”, “end_date”: “2024-03-29 11:17:42.000”}}] my objective is to create two

extract year_month from a date column along with other columns in a sql table

I have a sql table with multiple fields including (but not limited to the following): member_id, visit_date (in datetime format eg: 2016-01-01), visit_yr_qtr (as string, eg: 2016_Q1), purchase_item (ID number), and item_price (in US dollars). I would like to extract these fields, but also include year_month (2016- January or 2016-01)as a new field in the output. This is what I

If a string is enclosed in quotes either ” or ‘. I have to remove those starting and ending quotes in snowflake

Check the following input/output examples: Input: “”Nag”ndra”” -> Expected output: “Nag”ndra” Input: ‘N’agendra -> Expected output ‘N’agendra I tried the below query to implement that behavior, which is able to remove the starting and ending quotes. for second example it is given as N’agendra it should be ‘N’agendra Answer If you want to keep the starting ‘ then don’t use

DISTINCT from One table and INNER JOIN with another table in snowflake

I would like to: Join two tables Remove “queryGroupName” = ‘DELETE’ from the first table From the first table, get Id by deduping (distinct ID) Using this Id, inner join with another table For output, select only the second table SELECT “TABLE2”.* FROM (SELECT DISTINCT “Id” FROM DB1.”PUBLIC”.”TABLE1″) INNER JOIN DB1.”PUBLIC”.”TABLE2″ ON DB1.”PUBLIC”.”TABLE1″.”Id” = DB1.”PUBLIC”.”TABLE2″.”Id” WHERE “queryGroupName” not in (‘DELETE’);

Advertisement