How to display SQL query that ran in WC_Order_Query?

WC_Order_Query does not store a record of the SQL it generated, or the WP_Query that it used internally. So it’s not possible to get the information you need from WC_Order_Query directly.

You could try using $wpdb->last_query immediately after using the class or function, but the last query more than likely isn’t the one you’re actually looking for:

global $wpdb;

$orders = wc_get_orders();

$query = $wpdb->last_query;

Your best bet is to use a tool like Query Monitor, which will allow you to see all the SQL queries run during a page load. You could use this to inspect your query.