try
SELECT DISTINCT 'DROP TABLE DB1.' || TABLENAME || ' ;
' !! case when row_number() over (order by tablename) mod 10 = 0 then '.hang 50;' else '' end
FROM dbc.tables WHERE tablekind = 'T' AND databasename = 'DB1'
AND TRIM(tablename) LIKE any
('WK_%0','WK_%1','WK_%2','WK_%3','WK_%4','WK_%5','WK_% 6','WK_%7','WK_%8','WK_%9')
AND CAST(CreateTimeStamp AS DATE) < add_months(date - extract(day from date) + 1, -1)
;
↧