Skip to content
Advertisement

SQL. Get samples of data in group query

I have a simple table with only 2 columns:

I need a SQL query to get this data:

So, the first part is simple, just grouping by domain and getting names count. But the second part, where I need to take 5 samples (they can be random) of names in the group – I have no idea how to resolve it.

Advertisement

Answer

Below is for BigQuery Standard SQL

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement