I have fetching following data through query
select ord_date,sum(product_sales) product_sales from salestable group by ord_date
How can I the following data through query. I am using mySQL 5.7 version
CodePudding user response:
You need to use aggregate window functions with no partition by clause. Check below for the code.
SELECT
ord_date,
product_sales,
SUM(product_sales) OVER() as total_sales,
ROUND(AVG(product_sales) OVER(),2) as avg_sales
FROM Orders;
Result_Set:
[Result_01][1]