<s>[INST] Write a SQL code to count the number of orders for each unique merchant order reference.  [/INST] SELECT order_merchant_order_ref, COUNT(*) AS total_orders FROM order_transaction.transaction_detail_deprecated GROUP BY order_merchant_order_ref; </s>