title: Need help in query finding first and last item in item groups
body: <p>I need help in getting this type of output:</p>
  
  <pre><code>Create table T1
  (Id int identity primary key,
  VoucherNo varchar(10),
  TransNo varchar(10)
  )
  
  Insert into T1 values ('V100','Trns1'),('V101','Trns1'),('V102','Trns1'),('V103','Trns1'),('V104','Trns1'),('V106','Trns1')
  </code></pre>
  
  <p>Resultant output:</p>
  
  <pre><code>TransNo FirsvoucherNo  LastVoucherNo Quantity
  trans1    V100     V104  5
  trans1   V106      V106   1
  </code></pre>