string str = string.Format(@"select m.pcode, m.fyyear, m.salary, m.ta,
                           m.contigency, m.nrc, m.institcharges, m.others,
                           y.pcode as ypcode,y.fyyear as yfyear,y.yearlyalloc,
                           y.salary as sal1,y.ta as ta1,y.contigency as cont1,
                           y.nrc as nrc1,y.institcharges as inst1,
                           y.others as other1                                      
                           FROM monthly AS m inner join yearly y
                           on m.pcode=y.pcode 
                           where m.pcode=('" + DropDownList1.SelectedItem.ToString() 
                           + "' ) AND 
                             y.fyyear like('" + DropDownList2.SelectedItem.ToString()
                           + "')group by m.pcode,m.fyyear", con); 
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataTable dtNew = new DataTable();
da.Fill(dtNew);
GridView1.DataSource = dtNew;
GridView1.DataBind();
in this code the monthly table contains columns which I wanted to show in a this way:
select m.pcode, m.fyyear, sum(m.salary) as msal, sum(m.ta) as mta, 
sum(m.contigency) as m cont, sum(m.nr) as mnrc, sum(m.institcharges) as minstit, 
sum(m.others) as mothers  
FROM monthly AS m 
where m.pcode=('" + DropDownList1.SelectedItem.ToString() + "' )
and m.fyyear like('" + DropDownList2.SelectedItem.ToString() + "')
group by m.pcode,m.fyyear
and yearly table data as:
"selecet y.pcode as ypcode,y.fyyear as yfyear,y.yearlyalloc,y.salary as sal1,
 y.ta as ta1,y.contigency as cont1,y.nrc as nrc1,y.institcharges as inst1,
 y.others as other1 
 FROM yearly AS y
 where y.pcode=('" + DropDownList1.SelectedItem.ToString() + "' )
 and y.fyyear like('" + DropDownList2.SelectedItem.ToString() + "') 
 group by y.pcode,y.fyyear
I want these to combine these two queries the above compound query that I have written using join is working but its not allowing me to use sum and group by function. please help
 
    