mysql - Simple SQL Queries used in Ecommerce -
There are two tables: purchase collection, which includes audited, orderdate, user-side
Purchase_Details in which itemid Itemized [item in this area] "Books", "Music" is the name of the category, which is for the item) Item Payment [This field has been paid for that particular item]
< P> The column names themselves are interpretive, for a single order many can be idless. Question 1: As an output we need a list of all orders and their payments [Remember that the payment of the order will be the amount of payment for all items of that order] < P> Question 2: As an output we need a list of all user-side and total payment received by them in 2013. Question 3: We need a list of all the users, who have bought more than 10,000 rupees in 2012, but have not been bought at all in 2013. Question4: As an output we need a list of all the users who are in the year 2013, which are purchased from the category called "Books", called category "Music".
Please check my solution. I am getting the right result from the questions given below, if there are still ways to optimize the solution, please give me suggestions.
Ans1
Select Ordered, Yog (Item Payment) from the purchase_detail group based on the order;
Ans2.
a.userid, sum (b.itempayment) Select- as a left join in the form of total payment from buy_summary as buy_detail to a.orderid = B.orderid where year (order ) = '2013' group by userid;
Answer 3.
select userid from purchase_summary as an inbound join purchase_detail b on a.orderid = b.orderid where year (orderdate) = '2012' and no user id (Select URIID from UID, where year (order-date) = '2013') Equal (item payment) by user-facing> gt; 10000;
Ans4
Comments
Post a Comment