Before you run this query it is IMPERATIVE that you have a backup of your database. 45Squared is not responsible for any data loss or unwanted results. If you are unsure of what you are doing PLEASE contact us for help.
First, delete all of the order details and metadata. This will be sure that there isn’t any orphaned data in your database.
DELETE FROM wp_woocommerce_order_items WHERE order_id IN ( SELECT ID FROM wp_posts WHERE post_date >= '2019-01-01')
DELETE FROM wp_comments WHERE comment_type = 'order_note' AND comment_post_ID IN ( SELECT ID FROM wp_posts WHERE post_date >= '2019-01-01')
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND post_date >= '2019-01-01')