How To Do Percent/Total in SQL?

前端 未结 4 1601
梦如初夏
梦如初夏 2021-01-07 17:12

I have an typical CUSTOMER/ORDERS set of tables and I want to display the total percentage of sales a particular customer is responsible for. I can get the

4条回答
  •  灰色年华
    2021-01-07 17:25

    One solution is to use a nested query-

    SELECT count(*) / (SELECT count(*) FROM orders)
    FROM orders
    WHERE cust_id = 541
    

提交回复
热议问题