0

I have two simple queries

set recent_date = (select Max(FILE_DATE) from "PRODUCTS");

select P.*,V.ID as Var_ID,V.Name as Var_Name, V.external_id as Var_Ext_ID, V.color, V.original_price, V.Price
FROM "PRODUCTS" P
JOIN "VARIEY" V
    ON P.FILE_DATE = V.FILE_DATE
        AND P.ID = V.ID
WHERE P.FILE_DATE = $recent_date

I am calling the queries from Python(running them on snowflake is returning the result) I am using the python snowflake connector and capturing the results in a Pandas dataframe. I am trying to create a stored proc or any function so I can just call the proc/func instead of running the query again, I am new to snowflake and SP and unable to create one, Will appreciate any help

1 Answer 1

0

one option is you can create a view something like as follows and select from the view. If you want to create a user defined function , you can see the link below. https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-tabular-functions.html

CREATE VIEW VW_TST AS (
select P.*,V.ID as Var_ID,V.Name as Var_Name, V.external_id as Var_Ext_ID, V.color, V.original_price, V.Price
FROM "PRODUCTS" P
JOIN "VARIEY" V
    ON P.FILE_DATE = V.FILE_DATE
        AND P.ID = V.ID
WHERE P.FILE_DATE = (select Max(FILE_DATE) from "PRODUCTS")
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.