Damage share of refunds

reshaping

Damage share of refunds

Flipkart SQL Interview Question

Damage is the only return reason Flipkart can fix by spending money: better packaging and a different courier lane. The business case for that spend is the share of refunded rupees damage accounts for, not the share of returns. Ten cheap shirts torn in transit matter far less than one television.

Return the category, the money refunded there as total_refund, the part of it caused by damage as damaged_refund, and damage as a percentage of the category total as damaged_share, rounded to 2 decimal places.

Asked of

  • Data Analyst
  • Business Analyst
  • BI Analyst
  • Product Analyst
  • Analytics Engineer
  • Data Engineer
  • Data Scientist

flipkart_returnsTable26 rows

Column NameType
return_idBIGINT
order_idBIGINT
categoryVARCHAR
requested_onDATE
reasonVARCHAR
refund_amountDOUBLE

flipkart_returnsExample Input

return_idorder_idcategoryrequested_onreasonrefund_amount
300170011Apparel2024-08-01size issue1299
300270012Apparel2024-08-01damaged2499
300370013Electronics2024-08-02damaged15999
300470014Home2024-08-02not as described3499
300570015Apparel2024-08-03size issue899
300670016Electronics2024-08-03not as described7499
300770017Apparel2024-08-04size issue1599
300870018Home2024-08-04damaged2899

Example Output

categorytotal_refunddamaged_refunddamaged_share
Apparel6296249939.69
Electronics234981599968.09
Home6398289945.31

Explanation

Apparel refunded 6296 in total, of which 2499 was damage, a share of 39.69. Electronics refunded far more overall and damage accounts for 68.09 of it, which is the point: one broken television outweighs several torn shirts.

The example above is a small slice of the data. Your query runs against the full tables.