subject

My tables are: customer(cid, name, city, state)
orders(oid, cid, date)
product(pid, productname, price)
lineitem(lid, pid, oid, number, totalprice)
I want to create a view ProductMonth (PID, ProductName, Month, QuantitySold, NumberCus­tomer, Revenue) that gives for each the product and each month, the quantity sold, the number of distinct customers who bought the product and amount of money the sale corresponds to for the month.
I used extract() to get the months from orders. date. I need to know how to loop each month and each product. I couldn't come up with a working query. Is it even possible to do it in MySQL? I mean looping the product name for each month and calculating the total price and also how much each product sales contributed to the whole. I know how to implement this for a particular product or month but not for products sold in each month. I tried using joins but it fails. I need the query and also a logic to implement it.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:40
What are the three parts to physical security standards for various types of army equipment and the risk level
Answers: 2
question
Computers and Technology, 22.06.2019 10:40
"it security policy enforcement and monitoring" respond to the following: describe how monitoring worker activities can increase the security within organizations. describe the rationale that managers should use to determine the degree of monitoring that the organization should conduct. explain the extent to which you believe an organization has the right to monitor user actions and traffic. determine the actions organizations can take to mitigate the potential issues associated with monitoring user actions and traffic.
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
Which of the following is not an enhancement to the standard wiki to make it more attractive for corporations? encryptionwork spacespermission toolspredictive text
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
You know the right answer?
My tables are: customer(cid, name, city, state)
orders(oid, cid, date)
product(pid, pro...
Questions
question
Mathematics, 09.12.2021 04:40