SQL to multiply values on each row and then find the average
Posted on 2008-06-26
I have a table Customer with the following details
AcctID, Name, Ticket, Values
1 Bob 3 20
2 Bob 3 10
3 Bob 4 5
4 Bob 5 10
5 Bob 5 10
6 Karen 6 2
What I need to do is write a SQL query to multiply the values together for each ticket and then return the Average Value per user(Name). - The Average Value is the multiplied values for each ticket divided by the number of tickets.
Please can you help me write the SQL query to return the average values per user.