Advertisement
42ama

101

Feb 27th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. SELECT code, model, color, type, price,
  2. MAX(model) OVER(PARTITION BY partition ORDER BY code ASC),
  3. AVG(price) OVER(PARTITION BY partition ORDER BY code ASC)
  4. FROM
  5. (
  6. SELECT *,
  7. CASE
  8. WHEN color = 'n'
  9. THEN 1
  10. ELSE 0
  11. END AS partition
  12. FROM printer
  13. ) t
  14. ORDER BY code ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement