Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.69 KB | None | 0 0
  1. Input Dataset
  2.  
  3. AccountNO  AccountType Opening Date Serial      Due        Balance     
  4. ---------- ----------- ------------ ----------- ---------- --------    
  5. A1         A           05-Jan-2012      1        1000.00    2700.00    
  6. A1         A           05-Jan-2012      2        1000.00    2700.00    
  7. A1         A           05-Jan-2012      3        2000.00    2700.00    
  8. A1         A           05-Jan-2012      4        700.00     2700.00    
  9. A2         A           06-Jan-2012      1        100.00     2700.00    
  10. A2         A           06-Jan-2012      2        200.00     2700.00    
  11. A2         A           06-Jan-2012      2        500.00     2700.00    
  12. A3         A           07-Jan-2012      1        500.00     2700.00    
  13. A3         A           07-Jan-2012      2        700.00     2700.00    
  14. A3         A           07-Jan-2012      3        400.00     2700.00    
  15. B1         B           05-Jan-2012      1        1000.00    1100.00    
  16. B1         B           05-Jan-2012      2        1000.00    1100.00    
  17. B2         B           06-Jan-2012      1        100.00     1100.00    
  18. B2         B           06-Jan-2012      2        100.00     1100.00
  19.  
  20. Grouping will be done by AccountType.
  21. Priority will be set by Opening Date AND Serial.
  22.  
  23. A/C Type Opening    SL   Due     Balance    Remaining  Explanation 
  24. --- ---- ---------- ---- -----    --------  ---------  ------------
  25. A1   A   05-Jan-2012  1  1000.00  2700.00    2700.00    This row will be selected as output.
  26. A1   A   05-Jan-2012  2  1000.00  2700.00    1700.00    This row will be selected as output.
  27. A1   A   05-Jan-2012  3  2000.00  2700.00    700.00     This row will not be selected coz insufficient balance.
  28. A1   A   05-Jan-2012  4  700.00   2700.00    700.00     This row will not be selected as serial 3 for A1 is not selected.
  29. A2   A   06-Jan-2012  1  100.00   2700.00    700.00     This row will be selected as output.
  30. A2   A   06-Jan-2012  2  200.00   2700.00    600.00     This row will be selected as output.
  31. A2   A   06-Jan-2012  2  500.00   2700.00    400.00     This row will not be selected coz insufficient balance.
  32. A3   A   07-Jan-2012  1  500.00   2700.00    400.00     This row will not be selected coz insufficient balance.
  33. A3   A   07-Jan-2012  2  700.00   2700.00    400.00     This row will not be selected coz insufficient balance.
  34. A3   A   07-Jan-2012  3  400.00   2700.00    400.00     This row will not be selected as serial 1 & 2 for A3 is not selected.
  35. B1   B   05-Jan-2012  1  1000.00  1100.00    1100.00    This row will be selected as output.
  36. B1   B   05-Jan-2012  2  1000.00  1100.00    100.00     This row will not be selected coz insufficient balance.
  37. B2   B   06-Jan-2012  1  100.00   1100.00    100.00     This row will be selected as output.
  38. B2   B   06-Jan-2012  2  100.00   1100.00    0.00       This row will not be selected coz insufficient balance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement