HEY,
I HAVE TWO TABLES: CUSTOMERS AND USERS PER CUSTOMER
I NEED TO CREATE TWO CUSTOMERS GROUPS: DVIR & RON - 'CRNTER GROUP', AND DANNY & DAVID 'OTHER GROUP'.
AFTER THAT I NEED TO SUM THE NUMBER OF USERS FOR EACH GROUP.
I STARED BY USING UNION ALL AND PARTITION BY:
WITH "CUST-CTE" AS
(
SELECT ROW_NUMBER() OVER (ORDER BY NAME) RN , NAME
FROM CUSTOMERS
)
SELECT 'OTHER', NAME
FROM "CUST-CTE"
WHERE RN = 1
UNION ALL
SELECT 'OTHER', NAME
FROM "CUST-CTE"
WHERE RN = 2
UNION ALL
SELECT 'CENTER', NAME
FROM "CUST-CTE"
WHERE RN = 3
UNION ALL
SELECT 'CENTER', NAME
FROM "CUST-CTE"
WHERE RN = 4
AND NOW I AM STUCK WITH THE SUM, SHOWING HOW MANY USERS EACH GROUP HAS.
ANY HELP PLEASE?