I am using SQL Server 2012 & MATLAB. I have a table of 5 columns (1 char, 1 datetime and 3 floats). I have a simple query shown below that returns the data from this table which contains over a million records - this however causes an out of memory error in MATLAB.
simple query
select id_co, date_r, FAM_Score, FAM_A_Score, FAM_Score
from GSI_Scores
where id_co <> 'NULL'
order by id_co, date_rating
So I was looking to breakdown the query select the data in batches of 250,000 records. I have just come across the ROW_NUMBER function which I added to my query, please see below. This numbers all the records for me. However I am having trouble selecting say records between 250,000 and 500,000. How do I do this?
updated query
select id_co, date_r, FAM_Score, FAM_A_Score, FAM_Score, row_number() over (order by id_co) as num_co
from GSI_Scores
where id_co <> 'NULL' and num_sedol between 250000 and 500000
order by id_co, date_rating