mysql SELECT id title sum quantity as rating FROM books INNER JOIN sto

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
mysql> SELECT id,title,sum(quantity) as rating FROM books INNER JOIN store ON books.id = store.books_id
-> GROUP BY title
-> ORDER BY rating DESC;
mysql> SELECT id,title,sum(quantity) as rating FROM books,store,`order` WHERE status = 'выполнен'
-> and order_idorder = idorder
-> and books.id = store.books_id
-> GROUP BY title
-> ORDER BY rating DESC;
mysql> SELECT YEAR(time) as year, MONTH(time) as month, SUM(price) FROM `order` WHERE status IN ('выполнен','доставка')
-> GROUP BY year, month WITH ROLLUP;
mysql> SELECT idconsumer,fio,price FROM consumer,`order` WHERE consumer_idconsumer = idconsumer
-> HAVING price >= 2100;