Reputation: 1738
I've tried several routes to getting the 10 records from each subset of a large dataset and the best I can do is querying each subgroup explicitly in the query.
My first attempt from the (Teradata community help website) was this:
Select * FROM Table Qualify Row_number() Over (partition by date order by column) between 1 and 10;
I wanted this to work because I didn't want to manually go and harvest the partitions, but I run out of spool space when I try that. In the same forum there's this solution
FROM TheTable
SAMPLE WHEN TheDate = '2014-01-01' THEN 10
WHEN TheDate = '2014-2-01' THEN 10
...
END;
It works, but obviously is not dynamic to the dataset contents. Can I get a solution that is dynamic for large data sets?
Upvotes: 0
Views: 23