PRODUCTSALESPERCITY.sql

    0

    0

    ;

    The code selects the invoice's city name, product's product name, and the total price for each invoice item on the invoice.

    SELECT invoice.city_name,
    product.product_name,
    invoice_item.line_total_price
    FROM invoice_item as invoice_item
    JOIN product as product
    ON invoice_item.product_id = product.id
    JOIN (
      SELECT invoice.id,
      customer.city_name
      FROM invoice as invoice
      JOIN (
      SELECT customer.id,city.city_name
        FROM customer as customer
        LEFT JOIN city as city
        ON customer.city_id = city.id
      )as customer
      ON invoice.customer_id = customer.id
    ) as invoice
    ON invoice_item.invoice_id = invoice.id
    ORDER BY invoice_item.line_total_price DESC
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.