Goal is to select 10,000 records using the Priority_Flag by selecting records until quantity is met of 10,000 in the order of the Priority_Flag. So, select all records where Priority_Flag = 1A, then all for 2A which totals 5000. I only need 5000 more to meet my goal of 10000. So, last only select 5000 of 3A. Then stop process. Probably, something like enter 10000 for quantity needed. Then go check this Priority_Flag starting with 1A, 2A, 3A, 4A until desired quantity is met.
1A contains 2500 records; 2A contains 2500 records; 3A contains 10000 records; 4A contains 5000 records.
asked Apr 13 at 01:37 AM in Default
You could order your data according to the priority flag and then select the top 10000:
This way you are telling SQL declaratively what you need, rather than how to get the results (procedurally)
answered Apr 13 at 07:12 AM
Kev Riley ♦♦