G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 5th, 2020 130 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT *
  2. FROM (
  3.      SELECT DISTINCT C.CUSID||': '||C.CUS_NAME AS Customer,
  4.        RANK()
  5.            OVER (
  6.                ORDER BY COUNT(DISTINCT O.ORDER#) DESC
  7.                ) AS RANK1,
  8.        RANK()
  9.            OVER (
  10.                ORDER BY SUM(OD.QUOTED_PRICE*OD.NUM_ORDERED)/COUNT(DISTINCT OD.ORDER#) DESC
  11.                ) AS RANK2
  12. FROM CUSTOMER C
  13.     JOIN T_ORDERS O ON C.CUSID = O.CUSID
  14.     JOIN ORDER_DETAILS OD ON O.ORDER# = OD.ORDER#
  15.     GROUP BY C.CUSID||': '||C.CUS_NAME
  16.          )
  17. WHERE RANK1 <= 2 OR RANK2 <=2;
RAW Paste Data
Ledger Nano X - The secure hardware wallet
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