19. Loss-Making Manufacturers

Easy

drug_sales(product_id, manufacturer, sales, cogs)

Return the manufacturers with at least one product losing money, along with how many such products they have and the total amount lost as a positive number.

Return manufacturer, loss_product_count and total_loss, largest loss first, breaking ties by manufacturer.

A product that exactly breaks even is not a loss.

Tables

drug_sales

product_id  manufacturer  sales      cogs
----------  ------------  ---------  --------
1           Acme          50000.00   80000.00
2           Acme          10000.00   15000.00
3           Acme          90000.00   10000.00
4           Borne         20000.00   60000.00
5           Cole          70000.00   70000.00
6           Delta         100000.00  1000.00

Expected result

manufacturer  loss_product_count  total_loss
------------  ------------------  ----------
Borne         1                   40000.00
Acme          2                   35000.00

Sign in to write and run your own code.

Write one SELECT query