Hi All,
I will be writing a query to achieve something like below, please help me
TableName: Application
AppId (PK,int) AppType (bit)
1 0
2 0
3 0
4 0
5 1
6 0
7 0
8 0
9 1
10 1
11 0
12 0
13 1
14 0
15 1
I have to sequentially group App_Id based on App_type and create a batch of records. The important point to note is that I have to maintain the SEQUENCE of AppId while creating the batches. The maximum number of records a batch can have depends on batch size parameter (say batch size set to 3 for now). Once batch is created insert the details in a different table say called ApplicationBatch. So I want an output something like:
TableName: ApplicationBatch
BatchId MinAppId MaxAppId AppType
001 1 3 0
002 4 4 0
003 5 5 1
004 6 8 0
005 9 10 1
006 11 12 0
007 13 13 1
008 14 14 0
009 15 15 1
One more thing I have to design the query in a best efficient and optimized way because Application table can have more than million records in it.
Many thanks