how to sum all the returned rows I have a query which looks like:-

select ad.STUDENTMASTERID,ad.ADVERTISEMENTCODE, cod.POSTNAME,ad.CANDIDATENAMEINNEPALI, 
ad.PAYMENTSTATUS, cd.TOTALFEE, cod.CLASSNAME
from CANDIDATEAPPEARAGAINSTADVTCODE ad 
inner join CANDIDATEAPPEARTOADVTNUMBER cd on ad.STUDENTMASTERID = cd.STUDENTMASTERID
inner join ADVERTISEMENTCODE cod on cd.ADVERTISEMENTCODE = cod.ADVERTISEMENTCODE
WHERE ad.STUDENTMASTERID='415562' and ad.PAYMENTSTATUS='Pending' and 
cod.STATUSOFLASTDATEFORMSUBMISSION='Live';


this query returns two rows 

415562  15695-15698/2073-74 अमिन वा सो सरह  पुस्मिता कुमारी एेडी    Pending 300 रा.प.अनं द्वितीय
415562  15695-15698/2073-74 अमिन वा सो सरह  पुस्मिता कुमारी एेडी    Pending 150 रा.प.अनं द्वितीय


now i need to return only one row but the values of 6th column should be sum of each 6th columns of the each row. 

for eg here:- 

415562  15695-15698/2073-74 अमिन वा सो सरह  पुस्मिता कुमारी एेडी    Pending 450 रा.प.अनं द्वितीय
You need to use SUM() of TOTALFEE and GROUP BY the remaining column names.

The query will be:

SELECT ad.STUDENTMASTERID, ad.ADVERTISEMENTCODE, cod.POSTNAME, 
       ad.CANDIDATENAMEINNEPALI, ad.PAYMENTSTATUS, SUM(cd.TOTALFEE) AS TOTALFEE, cod.CLASSNAME
FROM CANDIDATEAPPEARAGAINSTADVTCODE ad
INNER JOIN CANDIDATEAPPEARTOADVTNUMBER cd ON ad.STUDENTMASTERID = cd.STUDENTMASTERID
INNER JOIN ADVERTISEMENTCODE cod ON cd.ADVERTISEMENTCODE = cod.ADVERTISEMENTCODE
WHERE ad.STUDENTMASTERID = '415562'
    AND ad.PAYMENTSTATUS = 'Pending'
    AND cod.STATUSOFLASTDATEFORMSUBMISSION = 'Live'
GROUP BY ad.STUDENTMASTERID, ad.ADVERTISEMENTCODE, cod.POSTNAME, 
       ad.CANDIDATENAMEINNEPALI, ad.PAYMENTSTATUS, cod.CLASSNAME;