[dba-SQLServer] SQL Server - selecting preferred records

Francisco Tapia fhtapia at gmail.com
Fri Nov 5 13:34:26 CDT 2010


If that's the case why not do a 

Select top 540000 * from (
Select fields from table where criteria 1
Union
Select fields from table where criteria 2
...
)

Sent from my mobile

On Nov 5, 2010, at 11:04 AM, jwcolby <jwcolby at colbyconsulting.com> wrote:

> The order is fulfilled as soon as I get 540K, from wherever they might come from.
> 
> John W. Colby
> www.ColbyConsulting.com
> 
> On 11/5/2010 11:24 AM, Francisco Tapia wrote:
>> are you trying to select an even number of records within the 540k? or is
>> the order fulfilled if the first group of records hits 540k?
>> 
>> 
>> -Francisco
>> http://bit.ly/sqlthis   | Tsql and More...
>> 
>> 
>> 
>> 
>> On Thu, Nov 4, 2010 at 7:51 AM, jwcolby<jwcolby at colbyconsulting.com>  wrote:
>> 
>>> I have a query where I need to select sets of records:
>>> 
>>> (Children_0_3 and income in(XYZ))
>>> (Children_4_7 and income in(XYZ))
>>> .
>>> .
>>> etc.
>>> (Age in (1,2) and income in (ABC))
>>> 
>>> I need to select the first group, then the next etc until I total 540K
>>> records.
>>> 
>>> Basically I need to select the records with something in any of the
>>> Children_X_Y fields
>>> and after that select from the last group.
>>> 
>>> Is there a way to do that directly in SQL?
>>> 
>>> 
>>> --
>>> John W. Colby
>>> www.ColbyConsulting.com
>>> _______________________________________________
>>> dba-SQLServer mailing list
>>> dba-SQLServer at databaseadvisors.com
>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>>> http://www.databaseadvisors.com
>>> 
>>> 
>> _______________________________________________
>> dba-SQLServer mailing list
>> dba-SQLServer at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>> http://www.databaseadvisors.com
>> 
>> 
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
> 




More information about the dba-SQLServer mailing list