I am a newbie to RedShift but experienced with MSSQL. I was wondering if there's any way to write an if-then-else logic in Redshift?
Basically I want to run this logic in Redshift:
if ((select count(*) from a) - (select count(*) from b)) = 0 then
drop table a;
Thanks in advance!
Redshift doesn't support procedural statements, so you handle this best in your application code. If you must do it inside of SQL, something along the lines of this may help:
delete from a where (select count(*) from a) = (select count(*) from b);
This doesn't drop the table but deletes all rows from it when your condition is met.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With