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 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
Apart from confidential information, what other information does nda to outline? ndas not only outline confidential information, but they also enable you to outline .
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Afashion designer wants to increase awareness about her brand. which network can she use and why she can use the blank to blank her products online. answers for the first blank: internet, extranet, or intranet answers for the second blank: market, design, and export
Answers: 1
You know the right answer?
My tables are: customer(cid, name, city, state)
orders(oid, cid, date)
product(pid, pro...
Questions
question
Chemistry, 29.01.2021 01:20
question
Mathematics, 29.01.2021 01:20
question
Mathematics, 29.01.2021 01:20
question
Mathematics, 29.01.2021 01:20
question
English, 29.01.2021 01:20
Questions on the website: 13722360