daily pastebin goal
77%
SHARE
TWEET

9

mrlis Jun 14th, 2018 (edited) 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH quantity_sales AS(
  2.     SELECT MAX(quantity) AS max_quantity,
  3.         prod_id
  4.     FROM (
  5.         SELECT prod_id,
  6.             time_id,
  7.             SUM(quantity_sold) AS quantity
  8.         FROM sh.sales
  9.         GROUP BY prod_id, time_id
  10.         ORDER BY quantity DESC, prod_id ASC)
  11.     GROUP BY prod_id
  12.     ORDER BY 1 DESC)
  13. SELECT max_quantity AS "Макс покуп/день",
  14.     prod_name
  15. FROM quantity_sales
  16. JOIN sh.products USING (prod_id)
  17. WHERE rownum <= 20
  18. ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top