Help me to write query for below

Copper Contributor

How many total orders were there in each month and how many of them were
returned? Add a column for return rate too.
return rate = (100.0 * total return orders) / total buy orders
Hint: You will need to combine SUM() with CASE WHEN


Database Description:
 Customers: Contains customer information, including cust_id, first_name, last_name,
email, phone, primary_pincode, gender, dob, joining_date.
 Products: Contains product information, including product_id, product_name, brand,
category, procurement_cost_per_unit, mrp.
 Pincode: Contains pincode-related information, including the pincode, city and state.
 Delivery Person: Contains information about delivery personnel, including
delivery_person_id, name, joining_date, pincode
 Orders: Contains order details, including order_id, order_type, cust_id, order_date,
product_id, delivery_person_id, payment_type, delivery_pincode

1 Reply

Database Description:

@Sathish_Kumar_Godugu , homework? Homework is for learning.

And that "description" isn't really one.

Please post table design as DDL, some sample data as DML statement and the expected result.