Monday, 16 June 2014

Company Sql Server

XL Health 16-06-2014
-------------------------------------
Q1) Select 1
     union
    Select 2
    Union
    Select 1 As ID
   Union
   Select 2 As ID,
   Union All
    Select 3


O/p=1
        2
        3

q2)
------------------------------
ID    NAme                     Amount      Total AMount
1 Reddy                100.00 100.00
2 SubbareddyReddy 200.00 300.00
3 OmReddy                600.00 900.00
5 Test                      100.00 1000.00
6 Test                       100.00 1100.00


Solution Is:

Select CID,CName,
Amount,
(Select Sum(Amount) From AutoSum S  where S.CID < A.CID+1 ) As Balance
From AutoSum A

No comments: