I need to find the list of
customer_id for customer who have spent more than the average customer.
This is the the query I use to generate table above:
SELECT customer_id, sum(Total) AS customer_total
FROM (SELECT T.order_id, customer_id, Total
FROM (SELECT order_id, SUM(quantity * B.price) AS Total
FROM ORDERITEM AS O, BOOK AS B
WHERE B.b_id = O.bid
GROUP BY O.order_id) AS A JOIN "TRANSACTION" AS T
ON A.order_id = T.order_id)
GROUP BY customer_id
ORDER BY customer_total DESC
How can I start from here to find the list of customers who have spent more than the average customer? And also how to give the limit of digits for double? Thanks in advance!
Below is the query I tried, but it returns empty. And I am sure the correct result is not empty.