SQLQuery Standard 20 customer_id
SELECT DIV(ROW_NUMBER() OVER() - 1, 20) AS customer_id, *
FROM `yourTable`
WITH `yourTable` AS (
SELECT login
FROM `ghtorrent-bq.ght_2017_04_01.users`
LIMIT 1000000
)
SELECT DIV(ROW_NUMBER() OVER() - 1, 20) AS customer_id, *
FROM `yourTable`
- customer_id
WITH `yourTable` AS (
SELECT login
FROM `ghtorrent-bq.ght_2017_04_01.users`
LIMIT 1000000
)
SELECT cnt, COUNT(1) AS distribution FROM (
SELECT customer_id, COUNT(1) AS cnt FROM (
SELECT *, DIV(ROW_NUMBER() OVER() - 1, 20) AS customer_id
FROM `yourTable`
ORDER BY customer_id
)
GROUP BY customer_id
)
GROUP BY cnt
ORDER BY cnt
Row cnt distribution
1 20 50000