Random sampling question

Database

Random sampling question

I have a issue where I want a random selection of transactions but need them each from a user that handled them. Each user would of touched 50-100 transactions and I need a sample of 3 from each agent. I know how to randomly grab transactions but not how to make sure i'm getting them from each agent not just random as a whole. 

1 REPLY
Teradata Employee

Re: Random sampling question

When you say you know 'how to randomly grab' what exactly do you mean?

Basically, what you need is RANK function with PARTITION on Agent, and put a QUALIFY on that RANK to filter only 3 rows.

HTH!