Can you properly help me with the next query?

Viewed 29

https://console.cloud.google.com/bigquery?hl=es&project=upbeat-resolver-362821&ws=!1m5!1m4!1m3!1supbeat-resolver-362821!2sbquxjob_7e8c9500_183679da577!3sUS

Hello, hoper everyone is doing great, today I am writting you because I recently present one big inconvenient related to the query, actually it is not running in SQL can you help me to find the specific solution related to this.

  1. Problem Statement: Identify and return records of warehouses that represents the percentage of orders that are fulfilled by each warehouse and consider which warehouses are delivering the most orders.

Here is some of the code information I have provided inside R

select warehouse.warehouse_id,
        concat (warehouse.state, “:”, warehouse.warehouse_alias) as warehouse_name, 
        count (orders.order_id) as number_of_orders, 
        (select count(*) from warehouse_orders.orders orders) As total_orders, 
        Case when 
            count(orders.order_id)/(select count (*) 
            from warehouse_orders.orders orders) <= 0.20
        then “fulfilled 0-20% of orders”
        when count (orders.order_id)/(select count (*) 
            from warehouse_orders.orders orders) > 0.20
            and count (orders.order_id)/(select count (*) 
                from warehouse_orders.order as orders) <= 0.60
        then “Fulfilled 21-60% of orders”
        else “Fulfilled more than 60% of orders”
        end as fulfillment_summary
FROM warehouse_orders.Warehouse Warehouse
    Left Join warehouse_orders.Orders Orders On orders.warehouse_id = Warehouse.warehouse_id
Group by warehouse.warehouse_id, warehouse_name
Having count (orders.order_id)>0 
0 Answers
Related