Sara
Sara

Reputation: 43

Select tables list based on a where condition in snowflake

Please help to find the table list based on a where condition. I am able to get table list in Snowflake using below query :

   select table_name 
   from information_schema.tables 
   where table_type = 'BASE TABLE' 
   and table_name like UPPER('DIM_STUDENT_NAME%');

All these tables have a timestamp column and my requirement is to find the list of tables where that timestamp column is less than 30days. Appreciate if someone can help me here.

Upvotes: 1

Views: 1384

Answers (1)

Ven
Ven

Reputation: 86

try add condition :

select table_name 
   from information_schema.tables 
   where table_type = 'BASE TABLE' 
   and table_name like UPPER('DIM_STUDENT_NAME%') and 
datediff(day, TableField,current_date() ) <= 30 

Upvotes: 0

Related Questions